数据好强啊QAQ

P3154 [CQOI2009] 循环赛

@[cx233666](/space/show?uid=70788) 数据好强啊,不记忆化死活过不去,另外,[cx233666](/space/show?uid=70788)是真的强
by yybyyb @ 2018-10-05 19:56:38


@[yybyyb](/space/show?uid=21283) tql 然而不记忆化可以过啊 ``` #include<cstdio> #include<cstring> #include<algorithm> #define gt getchar() #define ll long long #define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout) inline int in() { int k=0;char ch=gt; while(ch<'-')ch=gt; while(ch>'-')k=k*10+ch-'0',ch=gt; return k; } const int f[]={3,1,0,0}; int n,a[15],b[15],ans; void dfs(register int x,register int y) { if(b[x]>a[x])return; if(b[x]+(n-y+1)*3<a[x])return; if(x==n){++ans;return;} if(y==n) { register int t=a[x]-b[x]; if(t==2)return; b[y]+=f[t]; if(b[y]<=a[y])dfs(x+1,x+2); b[y]-=f[t]; } else { b[x]+=3;if(b[x]<=a[x])dfs(x,y+1);b[x]-=3; b[y]+=3;if(b[y]<=a[y])dfs(x,y+1);b[y]-=3; ++b[x],++b[y];dfs(x,y+1);--b[x],--b[y]; } } int main() { n=in(); for(register int i=1;i<=n;++i)a[i]=in(); dfs(1,2); printf("%d\n",ans); return 0; } ```
by Cgod @ 2018-10-05 20:03:01


不过还是没抢到最慢解QAQ
by Cgod @ 2018-10-05 20:03:26


|