QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#482743#7104. Halting ProblemYuanCH666WA 0ms3844kbC++141.2kb2024-07-17 21:08:572024-07-17 21:08:57

Judging History

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

  • [2024-07-17 21:08:57]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3844kb
  • [2024-07-17 21:08:57]
  • 提交

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 ? "AFFIRMATIVE" : "NEGATIVE");
	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:

NEGATIVE

result:

wrong answer 1st lines differ - expected: 'Yes', found: 'NEGATIVE'