思路:
水题,略过
Tip:
无
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 5; vector<int> v[maxn]; int cun[maxn]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { int t; cin >> t; for (int j = 1; j <= t; j++) { int p; cin >> p; v[i].push_back(p); } } int now = 1; while (m--) { int nop, j; cin >> nop >> j; if (nop == 0) now = v[now][j - 1]; else if (nop == 1) { cun[j] = now; cout << now << endl; } else if (nop == 2) now = cun[j]; } cout << now << endl; return 0; }