AcWing 3467. 哲哲打游戏
原题链接
中等
作者:
tire
,
2025-04-17 20:29:57
· 山西
,
所有人可见
,
阅读 2
#include <bits/stdc++.h>
using namespace std;
map<int,int> mm;
const int N = 1e6+10;
int a[N][110];
int b[N];
int main(){
ios::sync_with_stdio(0);
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++){
cin >> a[i][j];
}
}
int cur = 1;
while(m--){
int x;
cin >> x;
int y;
if(x == 0){
cin >> y;
cur = a[cur][y];
}else if(x == 1){
cin >> y;
b[y] = cur;
cout << cur << '\n';
}else{
cin >> y;
cur = b[y];
}
}
cout << cur << '\n';
return 0;
}