QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#61077 | #3827. Alan Turing | NYCU_Yamada# | AC ✓ | 0ms | 3588kb | C++20 | 1.2kb | 2022-11-09 20:03:17 | 2022-11-09 20:03:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef local
#define fastIO() void()
#else
#define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)
#endif
void solve() {
int N; scanf("%d ", &N);
vector<vector<array<int, 3>>> trans(N-1, vector<array<int, 3>>(3));
for (auto &vec : trans) for (auto &[x, y, z] : vec) {
scanf("%*c%d%*c %d%*c %d%*c ", &x, &y, &z), --x;
// printf("::: (%d)(%d)(%d)\n", x, y, z);
}
int M; cin >> M;
while (M--) {
int L; cin >> L;
vector<int> tape(30, 2);
for (int i = 0; i < L; ++i) cin >> tape[i+10];
int state = 0, pos = 10;
for (int _step = 1; _step <= 10 and state != N-1; ++_step) {
// printf("state = %d, pos = %d, tape = %d\n", state+1, pos-9, tape[pos]);
auto [x, y, z] = trans[state][tape[pos]];
tape[pos] = z, state = x, pos += y;
}
cout << (state == N-1 ? "yes" : "no") << "\n";
}
}
int32_t main() {
// fastIO();
int t = 1; cin >> t;
for (int _ = 1; _ <= t; ++_) {
cout << "Machine #" << _ << ":\n";
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3588kb
input:
20 1 98 9 1 1 1 0 0 1 0 0 1 5 0 0 0 0 0 6 0 0 1 1 0 1 5 1 0 1 1 0 9 1 1 1 1 1 0 0 1 0 10 0 1 1 1 1 1 0 1 1 1 5 0 1 1 1 1 7 1 1 0 1 1 1 0 6 1 0 1 1 0 0 9 1 1 0 0 0 1 1 1 0 7 0 0 0 1 1 1 0 7 1 0 1 0 1 0 1 9 0 0 1 0 1 1 1 1 1 9 1 0 1 1 0 1 1 1 0 8 0 1 1 0 1 0 0 1 6 0 0 1 0 0 0 10 1 0 1 0 0 0 0 0 1 1 10...
output:
Machine #1: yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes ...
result:
ok 1865 lines