QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#88845#3827. Alan TuringSorahISAAC ✓0ms3348kbC++201.2kb2023-03-17 19:33:172023-03-17 19:33:18

Judging History

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

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

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: 3348kb

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