评测链接
Code
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, m;
struct C
{
ll id, dir;
string name;
}cir[100100];
int main()
{
cin >> n >> m;
for (ll i = 1; i <= n; i++)
{
ll d; string s1; cin >> d >> s1;
cir[i].id = i, cir[i].dir = d, cir[i].name = s1;
}
ll pos = 1;
for (ll i = 1; i <= m; i++)
{
ll d, s;
cin >> d >> s;
if (cir[pos].dir == d)
{
pos = (pos - s + n) % n;
}
else
{
pos = (pos + s) % n;
}
}
cout << cir[pos].name;
return 0;
}