试试写循环展开
by Anguei @ 2018-02-02 15:30:30
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline void read(int &x)
{
x=0; int w=1; char c=getchar();
while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
x=x*w;
}
inline void write(int x)
{
if(x>=10) write(x/10);
putchar(x%10+'0');
}
const int f[4]={3,1,0,0};
int a[9],b[9],n,ans;
inline void dfs(int x,int y)
{
if(b[x]>a[x]) return;
if(b[x]+(n-y+1)*3<a[x]) return;
if(x==n&&b[x]==a[x]) {ans++; return;}
if(y==n)
{
int t=a[x]-b[x];
if(t==2) return;
b[y]+=f[t];
dfs(x+1,x+2);
b[y]-=f[t];
}
else
{
b[x]+=3; dfs(x,y+1); b[x]-=3;
b[y]+=3; dfs(x,y+1); b[y]-=3;
b[x]++; b[y]++; dfs(x,y+1); b[x]--; b[y]--;
}
}
int main()
{
read(n);
for(register int i=1;i<=n;i++) read(a[i]);
dfs(1,2);
write(ans);
return 0;
}
\\
by strangers @ 2018-02-02 15:31:56
@[yyfcpp](/space/show?uid=53062) = =
代码炸了不要在意....
手动开O3比O2还要慢...
inline read register write都写了
~~然而并没有什么卵用QAQ~~
by strangers @ 2018-02-02 15:33:16
@[strangers](/space/show?uid=52452) 那么我觉得你可以试试 10 小时之后再提交
by Anguei @ 2018-02-02 15:36:33
@[strangers](/space/show?uid=52452) 而且,n 这个变量用得比较多,应该写上 register 吧?
by Anguei @ 2018-02-02 15:37:37
@[yyfcpp](/space/show?uid=53062)
但是register不能给外面全局的变量定义啊
会CE的..只能给循环变量弄register吧..
by strangers @ 2018-02-02 15:39:49
@[yyfcpp](/space/show?uid=53062)
10个小时之后还行23333,,没有卡常特技很难受.......
by strangers @ 2018-02-02 15:43:38
@[strangers](/space/show?uid=52452) 那就在 main() 里面定义,到时候多传一个参数呗
by Anguei @ 2018-02-02 16:46:22
我卡在92分动不了了
by Sqrt_tyz @ 2018-08-07 22:09:18
+1
by powerLEO101 @ 2018-10-09 22:52:07