QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#49869 | #3827. Alan Turing | ckiseki# | AC ✓ | 4ms | 3644kb | C++ | 1.4kb | 2022-09-23 18:03:00 | 2022-09-23 18:03:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
assert(scanf("%d", &t) == 1);
for (int kase = 1; kase <= t; ++kase) {
printf("Machine #%d:\n", kase);
int n;
assert(scanf("%d", &n) == 1);
vector<array<array<int,3>,3>> a(n - 1);
for (auto &ai : a) {
for (auto &aij : ai) {
for (auto &aijk : aij)
while (scanf("%d", &aijk) != 1) getchar();
aij[0]--;
}
}
int q;
while (scanf("%d", &q) != 1) getchar();
while (q--) {
vector<int> mem(15, 2);
assert(mem.size() == 15);
int l; scanf("%d", &l);
for (int i = 0; i < l; ++i) {
int x; scanf("%d", &x);
mem.push_back(x);
}
for (int i = 0; i < 15; ++i)
mem.push_back(2);
int s = 0, p = 15;
bool done = false;
for (int o = 0; o < 10; ++o) {
if (s == n - 1) {
done = true;
break;
}
int c = mem[p];
auto [x, y, z] = a[s][c];
mem[p] = z;
s = x;
p += y;
}
done |= (s == n - 1);
cout << (done ? "yes" : "no") << '\n';
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 4ms
memory: 3644kb
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