#include<bits/stdc++.h>
using namespace std;
int n,m,ti=1;
string name[1000001];
bool fx[1000001];
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>fx[i]>>name[i];
}
for(int i=1;i<=m;i++){
int x,y;
cin>>x>>y;
if(x==0){
//面朝内部:左手顺时针,右手逆时针 0圈内
if(!fx[ti]){
ti-=(y-1);
}
if(fx[ti]){
ti+=(y-1);
}
}
if(x==1){
if(!fx[ti]){
ti+=(y-1);
}
if(fx[ti]){
ti-=(y-1);
}
}
//判断边界
while(ti<1){
ti=n+ti;
}
while(ti>n){
ti=ti-n;
}
}
cout<<name[ti];
return 0;
}
看了一下正解没啥区别?