QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#49869#3827. Alan Turingckiseki#AC ✓4ms3644kbC++1.4kb2022-09-23 18:03:002022-09-23 18:03:03

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-23 18:03:03]
  • 评测
  • 测评结果:AC
  • 用时:4ms
  • 内存:3644kb
  • [2022-09-23 18:03:00]
  • 提交

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