记录编号 549823 评测结果 AAAAAAAAAA
题目名称 [NOIP 2017]时间复杂度 最终得分 100
用户昵称 Gravatar夜莺 是否通过 通过
代码语言 C++ 运行时间 0.000 s
提交时间 2020-02-24 20:01:32 内存使用 0.00 MiB
显示代码纯文本
  1. #include<cstdio>
  2. #include<algorithm>
  3. #include<cstring>
  4. using namespace std;
  5. const int MAXN=200;
  6. char o[MAXN],x[MAXN],y[MAXN];
  7. int t,bl[MAXN],n[MAXN],stop,maxx;
  8. bool pd[MAXN];
  9. int T,l,num;
  10. char opt,k;
  11. bool what=false;
  12. void f();
  13. void e();
  14. void work(){
  15. scanf("%d %s",&l,o);
  16. maxx=stop=num=t=what=0;
  17. memset(pd,0,sizeof(pd));
  18. memset(bl,0,sizeof(bl));
  19. memset(n,0,sizeof(n));
  20. for(int i=0;i<l;i++){
  21. scanf("\n%c",&opt);
  22. if(opt=='F')
  23. f();
  24. else e();
  25. }
  26. if(what)return;
  27. if(t){
  28. printf("ERR\n");
  29. return;
  30. }
  31. if(o[2]=='1'){
  32. if(!maxx)
  33. printf("Yes\n");
  34. else printf("No\n");
  35. return;
  36. }
  37. int mi=0,w=4;
  38. while(o[w]!=')')
  39. mi=mi*10+o[w++]-'0';
  40. if(mi==maxx)
  41. printf("Yes\n");
  42. else printf("No\n");
  43. }
  44. void f(){
  45. scanf(" %c %s %s",&k,x,y);
  46. if(what)return;
  47. t++;
  48. int xx=0,yy=0,xl=0,yl=0;
  49. bl[t]=(int)k;
  50. if(pd[bl[t]]){
  51. what=true;
  52. printf("ERR\n");
  53. return;
  54. }
  55. pd[bl[t]]=true;
  56. if(!stop){
  57. if(x!="n")
  58. while(x[xl]>='0'&&x[xl]<='9')
  59. xx=xx*10+x[xl++]-'0';
  60. if(y!="n")
  61. while(y[yl]>='0'&&y[yl]<='9')
  62. yy=yy*10+y[yl++]-'0';
  63. if(((!xx&&yy)||(xx>yy&&yy))){
  64. stop=t;
  65. return;
  66. }
  67. if(xx&&!yy){
  68. num++;
  69. maxx=max(maxx,num);
  70. n[t]=1;
  71. return;
  72. }
  73. }
  74. }
  75. void e(){
  76. if(what)return;
  77. pd[bl[t]]=0;
  78. num-=n[t];
  79. n[t]=0;
  80. t--;
  81. if(t<0){
  82. printf("ERR\n");
  83. what=true;
  84. return;
  85. }
  86. if(t==0){
  87. num=0;
  88. }
  89. if(t==stop-1){
  90. stop=0;
  91. return;
  92. }
  93. }
  94. int Main(){
  95. freopen("2017complexity.in","r",stdin);
  96. freopen("2017complexity.out","w",stdout);
  97. scanf("%d",&T);
  98. for(int i=0;i<T;i++)
  99. work();
  100. return 0;
  101. }
  102. int uu=Main();
  103. int main(){;}