编程语言
首页 > 编程语言> > 2021团体程序设计天梯赛 L2-4 哲哲打游戏

2021团体程序设计天梯赛 L2-4 哲哲打游戏

作者:互联网

思路:

水题,略过

Tip:

#include <bits/stdc++.h>

using namespace std;

const int maxn = 100000 + 5;
vector<int> v[maxn];
int cun[maxn];

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        int t;
        cin >> t;
        for (int j = 1; j <= t; j++) {
            int p;
            cin >> p;
            v[i].push_back(p);
        }
    }
    int now = 1;
    while (m--) {
        int nop, j;
        cin >> nop >> j;
        if (nop == 0)
            now = v[now][j - 1];
        else if (nop == 1) {
            cun[j] = now;
            cout << now << endl;
        } else if (nop == 2)
            now = cun[j];
    }
    cout << now << endl;
    return 0;
}

  

标签:哲哲,int,cin,打游戏,L2,cun,maxn,now,nop
来源: https://www.cnblogs.com/Whiteying/p/14707810.html