QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#482750 | #7104. Halting Problem | YuanCH666 | WA | 1ms | 3772kb | C++14 | 1.2kb | 2024-07-17 21:11:35 | 2024-07-17 21:11:35 |
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 + 1) {
flag = true;
} else {
if (vis[i] == true) {
flag = false;
} else {
vis[i] = true;
if (s[n].cmd == "add") {
r += v;
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 {
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: 1ms
memory: 3772kb
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'