提交记录 20784


用户 题目 状态 得分 用时 内存 语言 代码长度
yzy4090 noip17b. 【NOIP2017】时间复杂度 Accepted 100 101.45 us 36 KB C++ 2.32 KB
提交时间 评测时间
2024-01-07 15:57:37 2024-01-07 15:57:49
#include<bits/stdc++.h>
using namespace std;bool var_exist[30];struct complexity{bool base;int comp;complexity(){base=0;comp=1;}complexity(int a,int b){base=a,comp=b;}void ini(){base=0;comp=1;}bool operator>(complexity another)const{if(base>another.base)return true;else if(base==another.base&&comp>another.comp)return true;return false;}}m;stack<char>sta_char;stack<complexity>sta_com;stack<bool>sta_into;void process(){m.ini();bool error=0;for(int i=0;i<30;i++)var_exist[i]=false;while(!sta_char.empty())sta_char.pop();while(!sta_com.empty())sta_com.pop();while(!sta_into.empty())sta_into.pop();int len;char str[10];scanf("%d O(%s\n",&len,str);bool base;int exp;if(str[0]=='1')base=0,exp=1;else base=1,sscanf(str,"n^%d)",&exp);while(len--){char op;scanf(" %c",&op);if(op=='F'){char var;int fromi,toi;string from,to;cin>>var>>from>>to;if(var_exist[var-'a'+1]==true){error=true;}sta_char.push(var);var_exist[var-'a'+1]=true;if(from!="n"&&to=="n"){if(!sta_com.empty()){complexity top=sta_com.top();if(top.base==0)sta_com.push(complexity{1,1});else sta_com.push(complexity{1,top.comp+1});if(sta_into.top()==0){if(sta_com.top()>m)m=sta_com.top();}}else{sta_com.push(complexity{1,1});if(sta_com.top()>m)m=sta_com.top();}if(!sta_into.empty())sta_into.push(sta_into.top());else sta_into.push(0);}else if(from=="n"&&to=="n"){if(!sta_com.empty())sta_com.push(sta_com.top());else sta_com.push(complexity{0,1});if(!sta_into.empty())sta_into.push(sta_into.top());else sta_into.push(0);if(sta_into.top()==0)if(sta_com.top()>m)m=sta_com.top();}else if(from=="n"&&to!="n"){if(!sta_com.empty())sta_com.push(sta_com.top());else sta_com.push(complexity{0,1});sta_into.push(1);}else if(from!="n"&&to!="n"){fromi=atoi(from.c_str());toi=atoi(to.c_str());if(fromi<=toi){if(!sta_com.empty())sta_com.push(sta_com.top());else sta_com.push(complexity{0,1});if(!sta_into.empty())sta_into.push(sta_into.top());else sta_into.push(0);}else{if(!sta_com.empty())sta_com.push(sta_com.top());else sta_com.push(complexity{0,1});sta_into.push(1);}if(sta_into.top()==0)if(sta_com.top()>m)m=sta_com.top();}}else{if(sta_char.empty()){error=true;continue;}var_exist[sta_char.top()-'a'+1]=false;sta_char.pop();sta_com.pop();sta_into.pop();}}if(!sta_char.empty()||error)puts("ERR");else if(base!=m.base||exp!=m.comp)puts("No");else puts("Yes");return;}int main(){int t;scanf("%d",&t);while(t--)process();return 0;}

CompilationN/AN/ACompile OKScore: N/A

Testcase #151.65 us36 KBAcceptedScore: 10

Testcase #240.45 us36 KBAcceptedScore: 10

Testcase #352.88 us36 KBAcceptedScore: 10

Testcase #468.17 us36 KBAcceptedScore: 10

Testcase #578.03 us36 KBAcceptedScore: 10

Testcase #659.09 us36 KBAcceptedScore: 10

Testcase #779.63 us36 KBAcceptedScore: 10

Testcase #897.95 us36 KBAcceptedScore: 10

Testcase #992.51 us36 KBAcceptedScore: 10

Testcase #10101.45 us36 KBAcceptedScore: 10


Judge Duck Online | 评测鸭在线
Server Time: 2024-05-06 18:57:54 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用