QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#204503#7104. Halting Problemjean#TL 10ms42724kbC++141.3kb2023-10-07 12:21:532023-10-07 12:21:53

Judging History

你现在查看的是最新测评结果

  • [2023-10-07 12:21:53]
  • 评测
  • 测评结果:TL
  • 用时:10ms
  • 内存:42724kb
  • [2023-10-07 12:21:53]
  • 提交

answer

#include"bits/stdc++.h"

using namespace std;

const int N = 1e6 + 10;

struct dream {
	int r, t;
	dream() {r = 0, t = 1;} 
	void add(int v) {
		r += v;
		r %= 256;
		t++;
	}
	void beq(int v, int k) {
		if(r == v) t = k;
		else t++;	
	}
	void bne(int v, int k) {
		if(r != v) t = k;
		else t++;
	}
	void blt(int v, int k) {
		if(r < v) t = k;
		else t++;
	}
	void bgt(int v, int k) {
		if(r > v) t = k;
		else t++;
	}
};

struct problem {
	string op;
	int v, k;
}p[N];

void solve() {
	int n;
	dream a;
	cin >> n;
	map<pair<int,int>,int> mp;
	for(int i = 1; i <= n; i++) {
		cin >> p[i].op >> p[i].v;
		if(p[i].op != "add") cin >> p[i].k;
	}
	while(a.t <= n) {
		//cout << a.r << " " << a.t << "\n";
		string op;
		int v, k;
		op = p[a.t].op, v = p[a.t].v, k = p[a.t].k;
		if(op == "add") {
			a.add(v); 
		}
		else if(op == "beq") {
			a.beq(v, k);
		}
		else if(op == "bne") {
			a.bne(v, k);
		}
		else {
			a.bgt(v, k);
		}
		if(!mp[{a.r, a.t}]) mp[{a.r, a.t}] = 1;
		else {
			cout << "No" << "\n";
			return ;
		}
	}
	cout << "Yes" << "\n";
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int t;
	cin >> t;
	while(t--) solve();
	return 0;
}
/*
4
2
add 1
blt 5 1
3
add 252
add 1
bgt 252 2
2
add 2
bne 7 1
3
add 1
bne 252 1
beq 252 1
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 10ms
memory: 42724kb

input:

4
2
add 1
blt 5 1
3
add 252
add 1
bgt 252 2
2
add 2
bne 7 1
3
add 1
bne 252 1
beq 252 1

output:

Yes
Yes
No
No

result:

ok 4 lines

Test #2:

score: -100
Time Limit Exceeded

input:

1117
8
bgt 51 8
add 75
add 115
bne 40 3
beq 213 6
bgt 210 4
blt 228 7
bgt 60 2
6
bne 130 3
add 33
bne 74 4
blt 73 6
blt 63 5
bne 138 2
6
beq 131 2
bgt 90 3
add 127
bgt 195 1
blt 244 6
bne 20 3
3
add 53
bne 122 1
blt 251 2
9
add 102
add 161
bne 26 2
blt 5 8
beq 76 3
add 119
bgt 196 3
bne 239 8
blt 15...

output:


result: