#include <bits/stdc++.h>
using namespace std;
const int N = 111111;
vector<int> st[N];//记录所有剧情
int sc[N];//记录存档信息
int main()
{
ios::sync_with_stdio(false);
//把cin cout的速度降低到和scanf printf接近 否则有一个点超时
int n, m, k, x, y;
cin >> n >> m;
for (int i = 1; i <= n; i++)
{
cin >> k;
for (int j = 0; j < k; j++)
{
cin >> x;
st[i].push_back(x);
}
}
int num = 1;
for (int i = 0; i < m; i++)
{
cin >> x >> y;
if (x == 0)
{
num = st[num][y-1];
}
else if (x == 1)
{
sc[y] = num;
cout << num << endl;
}
else if (x == 2)
{
num = sc[y];
}
}
cout << num << endl;
}
04-27
1563
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-14
1526
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-21
640
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-24