QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#158252 | #7104. Halting Problem | ucup-team1469# | AC ✓ | 139ms | 13808kb | C++17 | 3.3kb | 2023-09-02 16:21:14 | 2023-09-02 16:21:15 |
Judging History
answer
#ifndef LOCAL
#define FAST_IO
#endif
// ============
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define OVERRIDE(a, b, c, d, ...) d
#define REP2(i, n) for (i32 i = 0; i < (i32)(n); ++i)
#define REP3(i, m, n) for (i32 i = (i32)(m); i < (i32)(n); ++i)
#define REP(...) OVERRIDE(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
#define PER(i, n) for (i32 i = (i32)(n) - 1; i >= 0; --i)
#define ALL(x) begin(x), end(x)
using namespace std;
using u32 = unsigned int;
using u64 = unsigned long long;
using i32 = signed int;
using i64 = signed long long;
using f64 = double;
using f80 = long double;
template <typename T>
using Vec = vector<T>;
template <typename T>
bool chmin(T &x, const T &y) {
if (x > y) {
x = y;
return true;
}
return false;
}
template <typename T>
bool chmax(T &x, const T &y) {
if (x < y) {
x = y;
return true;
}
return false;
}
#ifdef INT128
using u128 = __uint128_t;
using i128 = __int128_t;
istream &operator>>(istream &is, i128 &x) {
i64 v;
is >> v;
x = v;
return is;
}
ostream &operator<<(ostream &os, i128 x) {
os << (i64)x;
return os;
}
istream &operator>>(istream &is, u128 &x) {
u64 v;
is >> v;
x = v;
return is;
}
ostream &operator<<(ostream &os, u128 x) {
os << (u64)x;
return os;
}
#endif
[[maybe_unused]] constexpr i32 INF = 1000000100;
[[maybe_unused]] constexpr i64 INF64 = 3000000000000000100;
struct SetUpIO {
SetUpIO() {
#ifdef FAST_IO
ios::sync_with_stdio(false);
cin.tie(nullptr);
#endif
cout << fixed << setprecision(15);
}
} set_up_io;
// ============
#ifdef DEBUGF
#else
#define DBG(x) (void)0
#endif
void solve() {
i32 n;
cin >> n;
Vec<tuple<string, i32, i32>> ins(n);
for (auto &[a, b, c] : ins) {
cin >> a >> b;
if (a != "add") {
cin >> c;
--c;
}
}
array<Vec<i32>, 256> seen;
fill(ALL(seen), Vec<i32>(n, 0));
i32 i = 0, v = 0;
while (i < n && !seen[v][i]) {
seen[v][i] = 1;
auto [a, b, c] = ins[i];
if (a == "add") {
v = (v + b) & 255;
++i;
} else if (a == "beq") {
if (v == b) {
i = c;
} else {
++i;
}
} else if (a == "bne") {
if (v != b) {
i = c;
} else {
++i;
}
} else if (a == "blt") {
if (v < b) {
i = c;
} else {
++i;
}
} else {
if (v > b) {
i = c;
} else {
++i;
}
}
}
if (i < n && seen[v][i]) {
cout << "No\n";
} else {
cout << "Yes\n";
}
}
int main() {
i32 t;
cin >> t;
while (t--) {
solve();
}
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3664kb
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: 0
Accepted
time: 139ms
memory: 13808kb
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:
ok 1117 lines
Extra Test:
score: 0
Extra Test Passed