这题读懂题目之后就发现它很呆
#include <bits/stdc++.h>
using namespace std;
const int N = 100010, M = 110;
vector<int> g[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++) {
int k;
cin >> k;
int u = i;
g[u].push_back(-1);
for (int j = 0; j < k; j++) {
int v;
cin >> v;
g[u].push_back(v);
}
}
int cur = 1;
map<int, int> onfile;
for (int i = 0; i < m; i++) {
int op, x;
cin >> op >> x;
if (op == 0) {
cur = g[cur][x];
} else if (op == 1) {
onfile[x] = cur;
cout << cur << "/n";
} else {
cur = onfile[x];
}
}
cout << cur;
return 0;
}
//1 -> 4 -> 3 -> 7 -> 8 -> 3 -> 5 -> 9 -> 10。
原创文章,作者:carmelaweatherly,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/244497.html