답안 #576323

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
576323 2022-06-13T02:57:41 Z eecs Through Another Maze Darkly (CCO21_day1problem3) C++17
0 / 25
917 ms 19680 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 800010;
int n, q, ptr[maxn];
vector<int> G[maxn];

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n >> q;
    for (int i = 1, k; i <= n; i++) {
        cin >> k;
        while (k--) {
            int c;
            cin >> c, G[i].push_back(c);
        }
    }
    while (q--) {
        ll k;
        cin >> k;
        fill(ptr + 1, ptr + n + 1, 0);
        int u = 1;
        do {
            u = G[u][++ptr[u] %= G[u].size()];
        } while (--k && u ^ 1);
        if (!k) { cout << u << "\n"; continue; }
        k %= 2 * n - 2;
        while (k--) u = G[u][++ptr[u] %= G[u].size()];
        cout << u << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 19028 KB Output is correct
2 Incorrect 917 ms 19680 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 19072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 19504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 19028 KB Output is correct
2 Incorrect 917 ms 19680 KB Output isn't correct
3 Halted 0 ms 0 KB -