class="markdown_views prism-atom-one-light">
Description
Solution
直接用加法减法+模即可。
复杂度:
O(n)
这么水的题我写来干嘛
Code
#include
#include
#include
#define fo(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=100500;
int n,m,ans;
int a[N];
int nm[N][15];
int main()
{
freopen("toy.in","r",stdin);
freopen("toy.out","w",stdout);
int q,w;char ch;
scanf("%d%d",&n,&m);
fo(i,0,n-1)
{
scanf("%d",&q);
a[i]=1;if(q)a[i]=-1;
ch=' ';
for(ch=' ';ch<'a'||ch>'z';ch=getchar());
while(ch<='z'&&ch>='a')nm[i][++nm[i][0]]=ch,ch=getchar();
}
ans=0;
fo(i,1,m)
{
scanf("%d%d",&q,&w);
if(q)q=1;else q=-1;
ans=(ans+q*a[ans]*w+n)%n;
}
fo(i,1,nm[ans][0])printf("%c",nm[ans][i]);
return 0;
}