哲哲打游戏
作者:
晴斋
,
2024-03-07 16:39:54
,
所有人可见
,
阅读 29
#include <iostream>
#include <vector>
using namespace std;
const int N = 1e5 + 10;
vector<int> g[N];
int n, m, record[N];
int main()
{
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i ++)
{
int j;
scanf("%d", &j);
for (int k = 1; k <= j; k ++)
{
int a;
scanf("%d", &a);
g[i].push_back(a);
}
}
int p = 1;
for (int i = 1; i <= m; i ++)
{
int a, b;
scanf("%d%d", &a, &b);
if (a == 0)
{
p = g[p][b-1];
}
else if (a == 1)
{
record[b] = p;
cout << p << endl;
}
else
{
p = record[b];
}
}
cout << p << endl;
return 0;
}