2021团体程序设计天梯赛 L2-4 哲哲打游戏
思路:
模拟
Tip:
L2中最简单的一道题了,题目虽长但是代码不长也很好理解
#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;
}

浙公网安备 33010602011771号