QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#482756 | #7104. Halting Problem | YuanCH666 | WA | 0ms | 3844kb | C++14 | 1.2kb | 2024-07-17 21:17:02 | 2024-07-17 21:17:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n, r, v, k;
string command;
bool vis[1001], flag;
struct x {
int k, v;
string cmd;
};
vector<x> s;
void f(int i) {
if (i > n) {
flag = true;
} else {
if (vis[i] == true) {
flag = false;
} else {
vis[i] = true;
if (s[n].cmd == "add") {
r = (r + v) % 256;
f(i + 1);
} else {
if (s[n].cmd == "beq") {
if (s[n].v == r) {
f(s[n].k);
} else {
f(i + 1);
}
} else {
if (s[n].cmd == "bne") {
if (s[n].v != r) {
f(s[n].k);
} else {
f(i + 1);
}
} else {
if (s[n].cmd == "blt") {
if (s[n].v < r) {
f(s[n].k);
} else {
f(i + 1);
}
} else {
if (s[n].cmd == "bgt") {
if (s[n].v > r) {
f(s[n].k);
} else {
f(i + 1);
}
}
}
}
}
}
}
}
}
int main() {
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> command >> v;
if (command == "add") {
s.push_back({0, v, "add"});
} else {
cin >> k;
s.push_back({k, v, command});
}
}
f(1);
cout << (flag ? "Yes" : "No");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3844kb
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:
No
result:
wrong answer 1st lines differ - expected: 'Yes', found: 'No'