#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define pbb pair<bool,bool>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xmod (ll)(1e9+7)
#define hmod 1286031825167LL
using namespace std;
int t,n,sum,now,len,num;
string comp,f,s;
char fe,va;
bool gg;
stack<pair<int,char> > st;
bool a[35];
void cal_now(){
if (comp.length() == 4)
now=0;
else
{
now=0; len=comp.length();
for (int j=4;j<len;j++){
if (comp[j] < '0' || comp[j] > '9')
break;
now*=10;
now+=comp[j]-'0';
}
}
for (int i=0;i<26;i++){
a[i]=false;
}
}
int str_val(string r){
int lenn=r.length(),numm=0;
for (int i=0;i<lenn;i++){
numm*=10;
num+=r[i]-'0';
}
}
int main(){
ios::sync_with_stdio(false);
// freopen("complexity.in","r",stdin);
// freopen("complexity.out","w",stdout);
cin >> t;
for (int i=1;i<=t;i++){
cin >> n >> comp; gg=false;
cal_now(); sum=0;
for (int j=1;j<=n;j++){
cin >> fe;
// cout << "nowgg:" << gg << "\n";
if (fe == 'F'){
cin >> va >> f >> s;
if (a[va-'a'])
gg=true;
if (gg)
goto out;
a[va-'a']=true;
if (s[0] == 'n')
st.push(mp(1,va));
else
if (f[0] == 'n')
st.push(mp(-100000,va));
else
{
if (str_val(f) <= str_val(s))
st.push(mp(0,va));
else
st.push(mp(-100000,va));
}
}
else
{
if (st.empty())
gg=true;
if (gg)
goto out;
a[st.top().y-'a']=false;
num=st.top().x; st.pop();
if (num < 0);
else
if (!st.empty())
st.top().x+=num;
else
sum=max(sum,num);
}
out:;
}
if (!st.empty() || gg)
cout << "ERR\n";
else
if (sum == now)
cout << "Yes\n";
else
cout << "No\n";
while (!st.empty()){
st.pop();
}
}
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 64.955 ms | 60 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #2 | 64.956 ms | 56 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #3 | 64.951 ms | 56 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #4 | 64.948 ms | 60 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #5 | 64.952 ms | 60 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #6 | 64.951 ms | 60 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #7 | 64.951 ms | 60 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #8 | 64.95 ms | 60 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #9 | 64.95 ms | 60 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #10 | 64.951 ms | 60 KB | Runtime Error | Score: 0 | 显示更多 |