提交记录 22383


用户 题目 状态 得分 用时 内存 语言 代码长度
neilliu noip17b. 【NOIP2017】时间复杂度 Accepted 100 169.17 us 40 KB C++ 1.72 KB
提交时间 评测时间
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;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #152.77 us40 KBAcceptedScore: 10

Testcase #241.07 us40 KBAcceptedScore: 10

Testcase #353.29 us40 KBAcceptedScore: 10

Testcase #471.17 us40 KBAcceptedScore: 10

Testcase #584.83 us40 KBAcceptedScore: 10

Testcase #659.1 us40 KBAcceptedScore: 10

Testcase #790.25 us40 KBAcceptedScore: 10

Testcase #8135.8 us40 KBAcceptedScore: 10

Testcase #9118.94 us40 KBAcceptedScore: 10

Testcase #10169.17 us40 KBAcceptedScore: 10


Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:22:41 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠