PTA L2-4 哲哲打游戏

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 1e5 + 50;
const int M = 110;

int arr[N];
vector<int>a[N];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        int k;
        cin >> k;
        for (int j = 1; j <= k; j++) {
            int x;
            cin >> x;
            a[i].push_back(x);
        }
    }
    int p = 1;
    while (m--) {
        int  op, b;
        cin >> op >> b;
        if (op == 0) {

            p = a[p][b-1];
        }
        else if (op == 1) {

            arr[b] = p;
            cout << p << endl;
        }
        else p = arr[b];
    }
    cout << p << endl;
}

凉心哥哥的小宝藏 文章被收录于专栏

c++

全部评论

相关推荐

11-06 16:50
门头沟学院 Java
用微笑面对困难:word打字比赛二等奖的我,也要来凑合凑合
点赞 评论 收藏
分享
用微笑面对困难:你出于礼貌叫了人一声大姐,大姐很欣慰,她真把你当老弟
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务