题目链接:https://www.luogu.com.cn/problem/P1563
解题思路:模拟题,按照题目要求进行操作即可。
实现代码如下:
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, m, type[maxn], a, s;
char name[maxn][11];
int main() {
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i ++) scanf("%d%s", type+i, name[i]);
int p = 0;
while (m --) {
scanf("%d%d", &a, &s);
p = ( p + n - ( type[p] ? 1 : -1 ) * (a ? 1 : -1) * s ) % n;
}
printf("%s
", name[p]);
return 0;
}