提交记录 20784
提交时间 |
评测时间 |
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;}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 51.65 us | 36 KB | Accepted | Score: 10 | 显示更多 |
Testcase #2 | 40.45 us | 36 KB | Accepted | Score: 10 | 显示更多 |
Testcase #3 | 52.88 us | 36 KB | Accepted | Score: 10 | 显示更多 |
Testcase #4 | 68.17 us | 36 KB | Accepted | Score: 10 | 显示更多 |
Testcase #5 | 78.03 us | 36 KB | Accepted | Score: 10 | 显示更多 |
Testcase #6 | 59.09 us | 36 KB | Accepted | Score: 10 | 显示更多 |
Testcase #7 | 79.63 us | 36 KB | Accepted | Score: 10 | 显示更多 |
Testcase #8 | 97.95 us | 36 KB | Accepted | Score: 10 | 显示更多 |
Testcase #9 | 92.51 us | 36 KB | Accepted | Score: 10 | 显示更多 |
Testcase #10 | 101.45 us | 36 KB | Accepted | Score: 10 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:45:03 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠