ICPC World Finals-ceiling Function

Source: Internet
Author: User
Tags modx

Make a direct contribution to a pseudo-hash, hash dafa good, hash a miracle

However, this is not a long time no brush problem, WA a lot of hair, Orz

#include <cstdio> #include <cstring> #include <algorithm> #include <map>using namespace std;# Define UL unsigned long longconst UL mod=1000000009;const ul modx=100000007;const int maxn=2008;struct fuck{int U,left,rig HT;} Edge[maxn];int tol;void init () {tol=0;} UL mody;void fuckbitch (int x) {edge[tol].u=x;edge[tol].left=-1;edge[tol].right=-1;tol++;} BOOL Dfs (int u,int x) {if (u==-1) {fuckbitch (x); return true;} if (edge[u].u>x) {if (Dfs (edge[u].left,x)) edge[u].left=tol-1;} Else{if (Dfs (edge[u].right,x)) edge[u].right=tol-1;} return false;} map<ul,int> mp;void Fuckdfs (int u,ul md) {mody=mody*modx+md;if (edge[u].left!=-1) Fuckdfs (Edge[u].left, (md< <1)); if (edge[u].right!=-1) Fuckdfs (Edge[u].right, (md<<1|1));} int main () {int t,i,j,x;int n,m;scanf ("%d%d", &n,&m); int sum=n;mp.clear (); for (i=1;i<=n;i++) {mody=0;init () ; for (j=1;j<=m;j++) {scanf ("%d", &x), if (j==1) fuckbitch (x); Elsedfs (0,x);} Fuckdfs (0,1); UL ans=mody;if (mp[ans]==0) mp[ans]++;elsesum--;} printf ("%d\n", sum); reTurn 0;  }

ICPC World Finals-ceiling Function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.