题目:玩具谜题
思路:直接模拟
代码:
#include<bits/stdc++.h>
using namespace std;#define maxn 100000
#define read(x) scanf("%d",&x)int n,m;
char nm[maxn+5][100];
int d[maxn+5];int main() {
read(n),read(m);for(int i=0;i<n;i++) {
read(d[i]);scanf("%s",nm[i]);}int ans=0;for(int i=1;i<=m;i++) {
int x,y;read(x),read(y);y%=n;if(d[ans]^x) {
ans=(ans+y)%n;} else {
ans=(ans-y+n)%n;}}printf("%s",nm[ans]);return 0;
}