【链接】
洛谷1563
【解题报告】
跟题目意思模拟。
#include<cstdio>
using namespace std;
const int maxn=100005,maxv=13;
int n,m,ans;
struct Name
{
int x;
char s[maxv];
}a[maxn];
inline int Read()
{
int res=0;
char ch=getchar();
while (ch<'0'||ch>'9') ch=getchar();
while (ch>='0'&&ch<='9') res=res*10+ch-48,ch=getchar();
return res;
}
int main()
{
freopen("1563.in","r",stdin);
freopen("1563.out","w",stdout);
n=Read(); m=Read();
for (int i=0; i<n; i++)
{
a[i].x=Read();
char ch=getchar(); int j=0;
while (ch<'a'||ch>'z') ch=getchar();
while (ch>='a'&&ch<='z') a[i].s[j++]=ch,ch=getchar(); a[i].s[j]='\0';
}
ans=0;
for (int i=1; i<=m; i++)
{
int x=Read(),p=Read();
if (x^a[ans].x) ans=(ans+p)%n; else ans=(ans-p+n)%n;
}
printf("%s",a[ans].s);
return 0;
}