其他分享
首页 > 其他分享> > L2-040 哲哲打游戏

L2-040 哲哲打游戏

作者:互联网

这题读懂题目之后就发现它很呆

#include <bits/stdc++.h>

using namespace std;

const int N = 100010, M = 110;
vector<int> g[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        int k;
        cin >> k;
        int u = i;
        g[u].push_back(-1);
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            g[u].push_back(v);
        }
    }   
    int cur = 1; 
    map<int, int> onfile;
    for (int i = 0; i < m; i++) {
        int op, x;
        cin >> op >> x;
        if (op == 0) {
            cur = g[cur][x];
        } else if (op == 1) {
            onfile[x] = cur;
            cout << cur << "\n";
        } else {
            cur = onfile[x];
        }
    }
    cout << cur;

    return 0;
}

//1 -> 4 -> 3 -> 7 -> 8 -> 3 -> 5 -> 9 -> 10。

标签:back,onfile,cur,哲哲,int,cin,打游戏,L2,op
来源: https://www.cnblogs.com/ZhengLijie/p/16153662.html