QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#159050#7104. Halting Problemucup-team1234#TL 7ms3536kbC++171.9kb2023-09-02 17:22:422023-09-02 17:22:42

Judging History

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

  • [2023-09-02 17:22:42]
  • 评测
  • 测评结果:TL
  • 用时:7ms
  • 内存:3536kb
  • [2023-09-02 17:22:42]
  • 提交

answer

/*
 * @Date: 2023-04-26 00:30:57
 * @Description: 请填写简介
 */
#include <bits/stdc++.h>

using i64 = long long;

template<typename A, typename B> std::ostream& operator<<(std::ostream &os, const std::pair<A, B> &p) {
	return os << '(' << p.first << ", " << p.second << ')';
}
template<typename T_container, typename T = 
typename std::enable_if<!std::is_same<T_container, std::string>::value, typename T_container::value_type>::type> 
std::ostream& operator<<(std::ostream &os, const T_container &v) { 
	os << '{'; std::string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}';
}
void debug_out() { std::cerr << std::endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { std::cerr << ' ' << H; debug_out(T...); }
#define debug(...) std::cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)

void solve() {
	int n;
	std::cin >> n;
	std::vector<std::string> s(n);
	std::vector<int> v(n), k(n);
	for(int i = 0; i < n; i ++) {
		std::cin >> s[i] >> v[i];
		if(s[i] != "add") {
			std::cin >> k[i];
			k[i] --;
		} else {
			k[i] = i + 1;
		}
	}
	int now = 0, id = 0, cnt = 0;
	while(id < n) {
		//std::cout << "debug: " << now << " " << id << "\n";
		if(s[id] == "add") {
			now = (now + v[id]) % 256;
			id ++;
		} else if(s[id] == "beq") {
			if(v[id] == now) {
				id = k[id];
			} else {
				id ++;
			}
		} else if(s[id] == "bne") {
			if(v[id] != now) {
				id = k[id];
			} else {
				id ++;
			}
		} else if(s[id] == "blt") {
			if(v[id] > now) {
				id = k[id];
			} else {
				id ++;
			}
		} else {
			if(v[id] < now) {
				id = k[id];
			} else {
				id ++;
			}
		}
		cnt ++;
		if(cnt == 2e5) {
			std::cout << "No\n";
			return;
		}
	}
	std::cout << "Yes\n";
}

int main() {
	std::cin.tie(nullptr)->sync_with_stdio(false);
	int _ = 1; std::cin >> _;
	while(_--) solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 7ms
memory: 3536kb

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
Time Limit Exceeded

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:


result: