记录编号 |
549823 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2017]时间复杂度 |
最终得分 |
100 |
用户昵称 |
夜莺 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.000 s |
提交时间 |
2020-02-24 20:01:32 |
内存使用 |
0.00 MiB |
显示代码纯文本
- #include<cstdio>
- #include<algorithm>
- #include<cstring>
- using namespace std;
- const int MAXN=200;
- char o[MAXN],x[MAXN],y[MAXN];
- int t,bl[MAXN],n[MAXN],stop,maxx;
- bool pd[MAXN];
- int T,l,num;
- char opt,k;
- bool what=false;
- void f();
- void e();
- void work(){
- scanf("%d %s",&l,o);
- maxx=stop=num=t=what=0;
- memset(pd,0,sizeof(pd));
- memset(bl,0,sizeof(bl));
- memset(n,0,sizeof(n));
- for(int i=0;i<l;i++){
- scanf("\n%c",&opt);
- if(opt=='F')
- f();
- else e();
- }
- if(what)return;
- if(t){
- printf("ERR\n");
- return;
- }
- if(o[2]=='1'){
- if(!maxx)
- printf("Yes\n");
- else printf("No\n");
- return;
- }
- int mi=0,w=4;
- while(o[w]!=')')
- mi=mi*10+o[w++]-'0';
- if(mi==maxx)
- printf("Yes\n");
- else printf("No\n");
- }
- void f(){
- scanf(" %c %s %s",&k,x,y);
- if(what)return;
- t++;
- int xx=0,yy=0,xl=0,yl=0;
- bl[t]=(int)k;
- if(pd[bl[t]]){
- what=true;
- printf("ERR\n");
- return;
- }
- pd[bl[t]]=true;
- if(!stop){
- if(x!="n")
- while(x[xl]>='0'&&x[xl]<='9')
- xx=xx*10+x[xl++]-'0';
- if(y!="n")
- while(y[yl]>='0'&&y[yl]<='9')
- yy=yy*10+y[yl++]-'0';
- if(((!xx&&yy)||(xx>yy&&yy))){
- stop=t;
- return;
- }
- if(xx&&!yy){
- num++;
- maxx=max(maxx,num);
- n[t]=1;
- return;
- }
- }
- }
- void e(){
- if(what)return;
- pd[bl[t]]=0;
- num-=n[t];
- n[t]=0;
- t--;
- if(t<0){
- printf("ERR\n");
- what=true;
- return;
- }
- if(t==0){
- num=0;
- }
- if(t==stop-1){
- stop=0;
- return;
- }
- }
- int Main(){
- freopen("2017complexity.in","r",stdin);
- freopen("2017complexity.out","w",stdout);
- scanf("%d",&T);
- for(int i=0;i<T;i++)
- work();
- return 0;
- }
- int uu=Main();
- int main(){;}