链接:Miku
暴力模拟
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
int n,m;
int ma[100001];
map <int,string> pl;
string s;
int f;
int x,y;
int id=1;
void sh(int st){
if(st+id>n)
id=st+id-n;
else
id=st+id;
}
void ni(int st){
if(st>=id)
id=n-(st-id);
else{
id=id-st;
}
}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i){
scanf("%d",&f);
cin>>s;
ma[i]=f;
pl[i]=s;
}
for(int i=1;i<=m;++i){
scanf("%d%d",&x,&y);
if(ma[id]){
if(x)
ni(y);
else
sh(y) ;
}else{
if(x)
sh(y);
else
ni(y);
}
}
cout<<pl[id];
return 0;
}