Bzoj 1028
The violent enumeration listens to that card, and that extra two cards, the rest of the mod3 after the simulation can be
1#include <cstdio>2 Const intmaxn=510;3 intn,m,a[maxn],b[maxn],cnt,ans[maxn],x;4 BOOLCheck ()5 {6 for(intI=1; i<=n;i++)7 if(a[i]>=2)8 {9 for(intj=1; j<=n+2; j + +) b[j]=A[j];Tenb[i]-=2;BOOLflag=true; One for(intj=1; j<=n;j++) A if(B[j]) - { - if(b[j]<0) {flag=false; Break;} the intt=b[j]%3; -b[j+1]-=t,b[j+2]-=T; - } - if(!flag | | b[n+1]<0|| b[n+2]<0)Continue; + return true; - } + return false; A } at - intMain () - { -scanf"%d%d",&n,&m); - for(intI=1; i<=3*m+1; i++) scanf ("%d", &x), a[x]++; - for(intI=1; i<=n;i++) in { -a[i]++; to if(Check ()) ans[++cnt]=i; +a[i]--; - } the if(cnt==0) {puts ("NO");return 0;} * for(intI=1; i<cnt;i++) printf ("%d", Ans[i]); printf"%d\n", ans[cnt]); $ return 0;Panax Notoginseng}
Bzoj 1028
Bzoj 1860
The number of direct DFS enumeration schemes, and then a hash of the weight can be, similar to the bucket landlord
1#include <cstdio>2#include <Set>3 #defineLL Long Long4 using namespacestd;5 ConstLL mod=1000000000000000003;6 Set<LL>S;7LL kase,bin[ the],a[ the],sum,mul=131ll;8InlineBOOLDfs (LL K,BOOLtwo,ll Sta)9 {Ten if(S.find (Sta)!=s.end ())return 0; One S.insert (Sta); A while(!a[k]&&k<= -) k++; - if(k==101)returnboth ; - if(a[k]&&a[k+1]&&a[k+2]&&k<=98) the { -a[k]--;a[k+1]--;a[k+2]--; - if(Dfs (K,two, (sta-bin[k]-bin[k+1]-bin[k+2]+3*MOD)%mod))return true; -a[k]++;a[k+1]++;a[k+2]++; + } - if(a[k]>=4) + { Aa[k]-=4; at if(Dfs (K,two, (sta-bin[k]*4+4*MOD)%mod))return true; -a[k]+=4; - } - if(a[k]>=3) - { -a[k]-=3; in if(Dfs (K,two, (sta-bin[k]*3+3*MOD)%mod))return true; -a[k]+=3; to } + if(a[k]>=2&&!Both ) - { thea[k]-=2; * if(Dfs (k,1, (sta-bin[k]*2-bin[ -]+3*MOD)%mod))return true; $a[k]+=2;Panax Notoginseng } - return false; the } + intMain () A { thebin[1]=1; for(intI=2; i<= -; i++) bin[i]= (bin[i-1]*mul)%Mod; +scanf"%d",&KASE); - for(intKase=1; kase<=kase; kase++) $ { $sum=0; - for(intI=1; i<= -; i++) scanf ("%lld", &a[i]), sum= (Sum+bin[i]*a[i])%Mod; - s.clear (); the if(Dfs (1,0, Sum)) puts ("Yes");ElsePuts"No"); - }Wuyi return 0; the}
Bzoj 1860
NOIP Pre-Test violence practice