$???$就一道紫题$???$,还是$D1T2\ ???$
简单的__模拟__,没的说
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| #include <bits/stdc++.h> using namespace std;
struct Node{ int towards; string name; } a[100001];
int n, m, ai, si;
int main() { cin >> n >> m; for (int i = 0; i < n; ++i) { cin >> a[i].towards >> a[i].name; } int peo = 0; for (int i = 1; i <= m; ++i) { cin >> ai >> si; if (ai == 0 && a[peo].towards == 0) peo = (peo + n - si) % n; else if (ai == 0 && a[peo].towards == 1) peo = (peo + si) % n; else if (ai == 1 && a[peo].towards == 0) peo = (peo + si) % n; else if (ai == 1 && a[peo].towards == 1) peo = (peo + n - si) % n; } cout << a[peo].name << endl; return 0; }
|