QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#694612#7104. Halting ProblemMine_King#AC ✓28ms14224kbC++141.2kb2024-10-31 18:19:262024-10-31 18:19:28

Judging History

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

  • [2024-10-31 18:19:28]
  • 评测
  • 测评结果:AC
  • 用时:28ms
  • 内存:14224kb
  • [2024-10-31 18:19:26]
  • 提交

answer

// 長い夜の終わりを信じながら
// Think twice, code once.
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#define eputchar(c) putc(c, stderr)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define eputs(str) fputs(str, stderr), putc('\n', stderr)
using namespace std;

int T, n, vis[10005][256];
struct node {string type; int v, k;} a[10005];

int dfs(int i, int r) {
	if (i == n + 1) return 1;
	if (vis[i][r]) return 0;
	vis[i][r] = 1;
	if (a[i].type == "add") return dfs(i + 1, (r + a[i].v) % 256);
	else if (a[i].type == "beq") return r == a[i].v ? dfs(a[i].k, r) : dfs(i + 1, r);
	else if (a[i].type == "bne") return r != a[i].v ? dfs(a[i].k, r) : dfs(i + 1, r);
	else if (a[i].type == "blt") return r < a[i].v ? dfs(a[i].k, r) : dfs(i + 1, r);
	else return r > a[i].v ? dfs(a[i].k, r) : dfs(i + 1, r);
}

int main() {
	scanf("%d", &T);
	while (T--) {
		scanf("%d", &n);
		for (int i = 1; i <= n; i++) {
			cin >> a[i].type;
			if (a[i].type == "add") scanf("%d", &a[i].v);
			else scanf("%d%d", &a[i].v, &a[i].k);
		}
		puts(dfs(1, 0) ? "Yes" : "No");
		for (int i = 1; i <= n; i++)
			for (int j = 0; j < 256; j++) vis[i][j] = 0;
	}
	return 0;
}

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

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 4152kb

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: 28ms
memory: 14224kb

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