比赛 Asm_Def战记之透明计算网络 评测结果 AAATTTTTTT
题目名称 Asm_Def排兵布阵 最终得分 30
用户昵称 fengchenxue 运行时间 7.003 s
代码语言 C++ 内存使用 1.08 MiB
提交时间 2015-11-01 10:44:59
显示代码纯文本
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<algorithm>
  4. #include<cmath>
  5. #include<queue>
  6. #include<vector>
  7. #include<cstring>
  8. #include<string>
  9. #include<cstdlib>
  10. using namespace std;
  11. int a[100010],n,num=0,place[100010];
  12. long long plan=0;
  13. void fun(int x)
  14. {
  15. if(x==num+1)
  16. {
  17. for(int i=2;i<=n;i++)
  18. {
  19. if(place[i]<=place[i-1]) return;
  20. }
  21. //printf("%d %d %d\n",place[1],place[2],place[3]);
  22. plan++;
  23. return;
  24. }
  25. for(int i=1;i<=n;i++)
  26. {
  27. if(a[i])
  28. {
  29. a[i]--;
  30. if(a[i]==0) place[i]=x;
  31. // printf("%d %d %d %d\n",x,place[1],place[2],place[3]);
  32. fun(x+1);
  33. if(a[i]==0) place[i]=0;
  34. a[i]++;
  35. }
  36. else continue;
  37. }
  38. }
  39. int main()
  40. {
  41. freopen("asm_formation.in","r",stdin);
  42. freopen("asm_formation.out","w",stdout);
  43. cin>>n;
  44. if(n==1)
  45. {
  46. if(n==1)
  47. cout<<"1";
  48. return 0;
  49. }
  50. for(int i=1;i<=n;i++)
  51. {
  52. scanf("%d",&a[i]);
  53. // cout<<a[i];
  54. num+=a[i];
  55. }
  56. fun(1);
  57. cout<<plan%998244353;
  58. return 0;
  59. }