比赛 |
Asm_Def战记之透明计算网络 |
评测结果 |
AAATTTTTTT |
题目名称 |
Asm_Def排兵布阵 |
最终得分 |
30 |
用户昵称 |
fengchenxue |
运行时间 |
7.003 s |
代码语言 |
C++ |
内存使用 |
1.08 MiB |
提交时间 |
2015-11-01 10:44:59 |
显示代码纯文本
- #include<iostream>
- #include<cstdio>
- #include<algorithm>
- #include<cmath>
- #include<queue>
- #include<vector>
- #include<cstring>
- #include<string>
- #include<cstdlib>
- using namespace std;
- int a[100010],n,num=0,place[100010];
- long long plan=0;
- void fun(int x)
- {
- if(x==num+1)
- {
- for(int i=2;i<=n;i++)
- {
- if(place[i]<=place[i-1]) return;
- }
- //printf("%d %d %d\n",place[1],place[2],place[3]);
- plan++;
- return;
- }
- for(int i=1;i<=n;i++)
- {
- if(a[i])
- {
- a[i]--;
- if(a[i]==0) place[i]=x;
- // printf("%d %d %d %d\n",x,place[1],place[2],place[3]);
- fun(x+1);
- if(a[i]==0) place[i]=0;
- a[i]++;
- }
- else continue;
- }
- }
- int main()
- {
- freopen("asm_formation.in","r",stdin);
- freopen("asm_formation.out","w",stdout);
- cin>>n;
-
- if(n==1)
- {
- if(n==1)
- cout<<"1";
- return 0;
- }
- for(int i=1;i<=n;i++)
- {
- scanf("%d",&a[i]);
- // cout<<a[i];
- num+=a[i];
- }
-
- fun(1);
- cout<<plan%998244353;
- return 0;
- }