QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#319427#7104. Halting ProblemDjangle162857#AC ✓18ms16220kbC++141.6kb2024-02-02 16:05:192024-02-02 16:05:20

Judging History

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

  • [2024-02-02 16:05:20]
  • 评测
  • 测评结果:AC
  • 用时:18ms
  • 内存:16220kb
  • [2024-02-02 16:05:19]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " == " << x << endl
#define el '\n'
typedef long long ll;
const int mod = 1000000007;
const int inf = 2147483647;
const int N = 100020;
int vis[N][256];
struct Data {
	int v, k, typ, x;
} q[N];
void solve() {
	int n;
	cin >> n;
	for (int i = 0; i <= n + 1; i++) {
		for (int j = 0; j < 256; j++) {
			vis[i][j] = 0;
		}
		q[i].typ = 0;
	}
	for (int i = 1; i <= n; i++) {
		string s;
		cin >> s;
		if (s[1] == 'd') {
			q[i].typ = 1;
			cin >> q[i].x;
		} else if (s[1] == 'e') {
			q[i].typ = 2;
			cin >> q[i].v >> q[i].k;
		} else if (s[1] == 'n') {
			q[i].typ = 3;
			cin >> q[i].v >> q[i].k;
		} else if (s[1] == 'l') {
			q[i].typ = 4;
			cin >> q[i].v >> q[i].k;
		} else if (s[1] == 'g') {
			q[i].typ = 5;
			cin >> q[i].v >> q[i].k;
		}
	}
	int pc = 1, r = 0;
	while (pc != n + 1) {
		if (vis[pc][r]) {
			cout << "No" << endl;
			return;
		}
		vis[pc][r] = 1;
		if (q[pc].typ == 1) {
			r = r + q[pc].x;
			r = r % 256;
			pc++;
		} else if (q[pc].typ == 2) {
			if (r == q[pc].v) {
				pc = q[pc].k;
			} else
				pc++;
		} else if (q[pc].typ == 3) {
			if (r != q[pc].v) {
				pc = q[pc].k;
			} else
				pc++;
		} else if (q[pc].typ == 4) {
			if (r < q[pc].v) {
				pc = q[pc].k;
			} else
				pc++;
		} else if (q[pc].typ == 5) {
			if (r > q[pc].v) {
				pc = q[pc].k;
			} else
				pc++;
		}
	}
	cout << "Yes" << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 5596kb

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: 0
Accepted
time: 18ms
memory: 16220kb

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:

No
Yes
Yes
No
No
Yes
Yes
No
Yes
No
No
No
No
Yes
No
No
Yes
No
Yes
No
No
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
Yes
No
Yes
No
No
No
Yes
No
No
No
No
No
Yes
No
Yes
Yes
Yes
No
Yes
No
Yes
No
Yes
No
No
No
No
Yes
No
No
Yes
No
No
Yes
No
No
No
Yes
Yes
Yes
Yes
No
Y...

result:

ok 1117 lines

Extra Test:

score: 0
Extra Test Passed