提交记录 11317


用户 题目 状态 得分 用时 内存 语言 代码长度
MicDZ noip17b. 【NOIP2017】时间复杂度 Accepted 100 85.67 us 52 KB C++ 2.27 KB
提交时间 评测时间
2019-11-14 22:14:41 2020-08-01 02:42:19
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>

using namespace std;

#define REP(i,e,s) for(register int i=(e); i<=(s); i++)
#define DREP(i,e,s) for(register int i=(e); i>=(s); i--)
#define ll long long
#define DE(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG(a) DE("DEBUG: %d\n",a)
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
int read() {
	int x=0,f=1,ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=1000+10,INF=0x3f3f3f3f;

struct edge {
	char first;int second,third;
};
edge make_pair(char a,int b,int third) {return (edge){a,b,third};}
struct stack {
	edge s[MAXN];
	int tp;
	stack() {tp=0;s[0].first=0,s[0].second=0,s[0].third=0;}
	void push(edge x) {s[++tp]=x;}
	edge top() {return s[tp];}
	void pop() {tp--;}
	int size() {return tp;}
} ;

map<char,int> mp;

int main() {
	int t=read();
	while(t--) {
		stack sta;
		char op[2],du[9+10];
		int L=read(),ori=0;
		scanf("O(%s",du+1);
		int len=strlen(du+1);
		if(len==2) ori=0;
		else REP(i,3,len-1) ori=ori*10+du[i]-'0';
		int ans=0;bool flag=0;
		
		REP(l,1,L) {
			scanf("%s",op+1);
			ans=max(ans,sta.top().second);
			
			if(op[1]=='F') {
				char var[3],e[30],s[30];
				scanf("%s%s%s",var+1,e+1,s+1);
				if(mp[var[1]]) {
					flag=1;
				}
				mp[var[1]]=1;
				
				int oe=0,os=0;
				if(e[1]=='n') oe=1;
				if(s[1]=='n') os=1;
				
				int nume=0,nums=0;
				
				if(!oe) REP(i,1,strlen(e+1)) nume=nume*10+e[i]-'0'; else nume=INF;
				if(!os) REP(i,1,strlen(s+1)) nums=nums*10+s[i]-'0'; else nums=INF;
				if((!oe&&os)&&(sta.top().third||(!sta.size()))) sta.push(make_pair(var[1],sta.top().second+1,1));
				else if((!oe&&!os)&&(nume<nums)&&(sta.top().third||(!sta.size()))) sta.push(make_pair(var[1],sta.top().second,1));
				else if(nums<nume) sta.push(make_pair(var[1],sta.top().second,0));
				else sta.push(make_pair(var[1],sta.top().second,sta.top().third));
			}
			if(op[1]=='E') {
				char var=sta.top().first;
				mp[var]=0;
				if(!sta.size()) {
					flag=1;
				}
				sta.pop();
			}

		}

		DE("%d %d\n",ori,ans);
		if(flag) {puts("ERR");continue;}
		if(sta.size()) puts("ERR");
		else if(ans==ori) puts("Yes");
		else puts("No");
		mp.clear();
	}
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #140.17 us52 KBAcceptedScore: 10

Testcase #246.84 us52 KBAcceptedScore: 10

Testcase #351.75 us52 KBAcceptedScore: 10

Testcase #451.44 us52 KBAcceptedScore: 10

Testcase #557.69 us52 KBAcceptedScore: 10

Testcase #647.48 us52 KBAcceptedScore: 10

Testcase #757.91 us52 KBAcceptedScore: 10

Testcase #875.26 us52 KBAcceptedScore: 10

Testcase #967.72 us52 KBAcceptedScore: 10

Testcase #1085.67 us52 KBAcceptedScore: 10


Judge Duck Online | 评测鸭在线
Server Time: 2024-04-23 23:10:32 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用