QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#242814#7104. Halting ProblemwushiWA 96ms20156kbC++141.6kb2023-11-07 17:31:512023-11-07 17:31:52

Judging History

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

  • [2023-11-07 17:31:52]
  • 评测
  • 测评结果:WA
  • 用时:96ms
  • 内存:20156kb
  • [2023-11-07 17:31:51]
  • 提交

answer

#include<bits/stdc++.h>
#define fi first
#define se second
//#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
int mod = 1e9 + 7, mod2 = 998244353;
const long long LNF = 0x3f3f3f3f3f3f3f3f;
const int N = 1e5 + 10, INF = 0x3f3f3f3f;
ll n, m, k;
int qmi(int a, int b) {
	ll res = 1;
	while (b) {
		if (b & 1)res = res * a % mod;
		a = (ll)a * a % mod;
		b >>= 1;
	}
	return res;
}
string s[N];
int st[N][300];
array<ll, 2>w[N];
void solve() {
	cin >> n;
	ll val = 0;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		ll x, y;
		cin >> x;
		if (s[i] != "add")cin >> y;
		w[i] = {x, y};
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 256; j++) {
			st[i][j] = 0;
		}
	}
	int nw = 1;
	while (nw != n + 1) {
		if (st[nw][val] == 1) {
			cout << "No" << '\n';
			return;
		}
		st[nw][val] = 1;
		if (s[nw] == "add") {
			val = (val + w[nw][0]) % 256;
			nw++;
		} else if (s[nw] == "beq") {
			if (val == w[nw][0]) {
				nw = w[nw][1];
			} else nw++;
		} else if (s[nw] == "bne") {
			if (val != w[nw][0]) {
				nw = w[nw][1];
			} else nw++;
		} else if (s[nw] == "blt") {
			if (val <= w[nw][0]) {
				nw = w[nw][1];
			} else nw++;
		} else if (s[nw] == "bgt") {
			if (val >= w[nw][0]) {
				nw = w[nw][1];
			} else nw++;
		}
	}
	cout << "Yes" << '\n';
}
signed main() {
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(2);
	int T = 1;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 9540kb

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
Wrong Answer
time: 96ms
memory: 20156kb

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:

wrong answer 89th lines differ - expected: 'Yes', found: 'No'