题目:https://www.luogu.org/problemnew/show/P1563
模拟水题。
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N=1e5+5,M=15; int n,m,a[N],cr; char ch[N][M]; int rdn() { int ret=0;bool fx=1;char ch=getchar(); while(ch>'9'||ch<'0'){if(ch=='-')fx=0;ch=getchar();} while(ch>='0'&&ch<='9') ret=(ret<<3)+(ret<<1)+ch-'0',ch=getchar(); return fx?ret:-ret; } int main() { n=rdn(); m=rdn(); for(int i=1;i<=n;i++) scanf("%d %s",&a[i],ch[i]); cr=1; for(int i=1,op,s;i<=m;i++) { op=rdn(); s=rdn(); if(op^a[cr])//+ { cr+=s;if(cr>n)cr-=n; } else { cr-=s;if(cr<=0)cr+=n; } } printf("%s ",ch[cr]); return 0; }