提交记录 22383
提交时间 |
评测时间 |
2024-08-19 15:18:37 |
2024-08-19 15:18:40 |
#include <bits/stdc++.h>
using namespace std;
int opt[105],x[105],y[105];
char name[105];
char nowyong[30];
int duiying[105];
int L;
string s;
int ans;
int zhuan(string num){
int cnt = 0;
for(int i = 0; i < num.size(); i++){
cnt = cnt + pow(10,(num.size() - 1 - i)) * (num[i] - '0');
}
return cnt;
}
void solve(){
memset(nowyong,0,sizeof(nowyong));
memset(duiying,0,sizeof(duiying));
scanf("%d",&L);
string s; cin >> s;
if(s.size() == 4) ans = 0;
else if(s.size() == 6) ans = (s[4] - '0');
else if(s.size() == 7) ans = (s[4] - '0') * 10 + (s[5] - '0');
for(int i = 1; i <= L; i++){
char tmp; cin >> tmp;
if(tmp == 'F') opt[i] = 0;
else opt[i] = 1;
if(tmp =='F'){
cin >> name[i];
string num; cin >> num;
if(num == "n") x[i] = 1e8;
else x[i] = zhuan(num);
cin >> num;
if(num == "n") y[i] = 1e8;
else y[i] = zhuan(num);
}
}
stack<char> s1;
stack<int> s2;
int nowfu = 0,nowmax = 0;
for(int i = 1; i <= L; i++){
if(opt[i] == 0){
if(nowyong[name[i] - 'a'] == 1){
printf("ERR\n");
return ;
}else s1.push(name[i]),s2.push(i),nowyong[name[i] - 'a'] = 1;
}
if(opt[i] == 1){
if(s1.size() == 0){
printf("ERR\n");
return ;
}
char ding = s1.top();
duiying[i] = s2.top(),duiying[s2.top()] = i;
nowyong[ding - 'a'] = 0;
s1.pop(),s2.pop();
}
}
if(s1.size() != 0){
printf("ERR\n");
return ;
}
for(int i = 1; i <= L; i++){
if(opt[i] == 0){
if(y[i] - x[i] < 0){
i = duiying[i]; continue;
}
if(y[i] - x[i] >= 200) nowfu++,nowmax = max(nowmax,nowfu);
}
if(opt[i] == 1) if(y[duiying[i]] - x[duiying[i]] >= 200) nowfu--;
}
if(nowmax == ans) printf("Yes\n");
else printf("No\n");
}
int main()
{
int T; scanf("%d",&T);
while(T--) solve();
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 52.77 us | 40 KB | Accepted | Score: 10 | 显示更多 |
Testcase #2 | 41.07 us | 40 KB | Accepted | Score: 10 | 显示更多 |
Testcase #3 | 53.29 us | 40 KB | Accepted | Score: 10 | 显示更多 |
Testcase #4 | 71.17 us | 40 KB | Accepted | Score: 10 | 显示更多 |
Testcase #5 | 84.83 us | 40 KB | Accepted | Score: 10 | 显示更多 |
Testcase #6 | 59.1 us | 40 KB | Accepted | Score: 10 | 显示更多 |
Testcase #7 | 90.25 us | 40 KB | Accepted | Score: 10 | 显示更多 |
Testcase #8 | 135.8 us | 40 KB | Accepted | Score: 10 | 显示更多 |
Testcase #9 | 118.94 us | 40 KB | Accepted | Score: 10 | 显示更多 |
Testcase #10 | 169.17 us | 40 KB | Accepted | Score: 10 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:22:41 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠