Topic links
At first glance, we think of the binary map.
1#include <algorithm>2#include <iostream>3#include <cstdlib>4#include <cstring>5#include <cstdio>6#include <string>7#include <cmath>8#include <ctime>9#include <queue>Ten#include <stack> One#include <map> A#include <Set> - #defineRre (i,r,l) for (int i= (r); i>= (l); i--) - #defineRe (I,L,R) for (int i= (l); i<= (R); i++) the #defineClear (A, B) memset (A,b,sizeof (a)) - #defineInOut (x) printf ("%d", (x)) - #defineDouin (x) scanf ("%lf", &x) - #defineStrin (x) scanf ("%s", (x)) + #defineLLin (x) scanf ("%lld", &x) - #defineOP operator + #defineCSC Main Atypedef unsignedLong LongULL; attypedefConst intCInt; -typedefLong LongLL; - using namespacestd; - voidInin (int&ret) - { -ret=0;intf=0;CharCh=GetChar (); in while(ch<'0'|| Ch>'9'){if(ch=='-') f=1; ch=GetChar ();} - while(ch>='0'&&ch<='9') ret*=Ten, ret+=ch-'0', ch=GetChar (); toret=f?-Ret:ret; + } - inthead[1000010],next[2000020],zhi[2000020],ed,n,pre[1000010],bo[1000010]; the BOOLFindintXintT) * { $ for(intI=head[x];i;i=Next[i])Panax Notoginseng if(bo[zhi[i]]!=T) - { thebo[zhi[i]]=T; + if(!pre[zhi[i]]| |find (pre[zhi[i]],t)) A { thepre[zhi[i]]=x; + return 1; - } $ } $ return 0; - } - voidAddintAintb) {next[++ed]=head[a],head[a]=ed,zhi[ed]=b;} the intCSC () - {Wuyi inin (n); theRe (I,1, N) - { Wu intX;inin (x), add (x,i); - inin (x), add (x,i); About } $Re (I,1, n+1)if(!find (i,i)) - { -printf"%d", I-1); - return 0; A } +cout<<N; the return 0; -}
bzoj1854 [Scoi2010] Games