3198: [sdoi2013]springtime limit:40 Sec Memory limit:256 MB
submit:1143 solved:366
[Submit] [Status] [Discuss] Description
Input
Output
Sample Input
3 3
1 2 3 4 5 6
1 2 3 0 0 0
0 0 0 4 5 6 Sample Output
2 HINT
Dragonite Correcting Data Source
Hash
simple
, but hash is a bit troublesome.
Ans= at least the logarithm of K *c (K,K)-at least k+1 logarithmic *c (k+1,k) + at least k+2 logarithmic *c (k+2,k) ...
For this C (i+k,k), my understanding of this logarithm was computed C (k+i,k) times
Hash judgment conflict.
at least I will not, others blog learned a wave
#include <cstdio>#include<iostream>#include<algorithm>#include<cstring>#definell Long Long#defineN 100005#defineMoD 2150527using namespacestd;inta[n][Ten],bin[Ten],hd[mod+Ten],vis[mod+Ten],c[Ten][Ten],sum[n],nxt[n],n,m;ll Val[n];voidPre () { for(intI=0; i<=6; i++) c[i][0]=c[i][i]=1; for(intI=1; i<=6; i++) for(intj=1; j<i;j++) C[i][j]=c[i-1][j-1]+c[i-1][j];} LL Calc (intSt) {ll ans=0;inttot=0; for(intI=1; i<=n;i++) {ll tmp=0;intj,k; for(j=1; j<=6; j + +)if(st&bin[j-1]) tmp=tmp*1000003+A[i][j]; J=tmp%mod;j<0? J+=mod:1; if(vis[j]!=st) {vis[j]=st;hd[j]=0;} for(k=hd[j];k;k=Nxt[k]) { if(val[k]==tmp) {ans+=sum[k];sum[k]++; Break; } } if(!k) {val[++tot]=tmp; Sum[tot]=1; nxt[tot]=hd[j];hd[j]=tot; } } returnans;}intMain () {scanf ("%d%d",&n,&m); for(intI=1; i<=n;i++) for(intj=1; j<=6; j + +) scanf ("%d",&A[i][j]); bin[0]=1;p Re (); for(intI=1; i<=8; i++) bin[i]=bin[i-1]<<1; ll ans=0; for(intI=0;i< -; i++){ intCnt=0; for(intj=0;j<6; j + +) if(I&bin[j]) cnt++; if(cnt<m)Continue; ll T=calc (i) *C[cnt][m]; if((cnt-m)%2) ans-=T; Elseans+=T; } cout<<ans; return 0;}
Bzoj3198[sdoi2013]spring +hash