WA on #4 #8
Code:
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+7;
int n,m,now=1,turn;
struct person{
string name; bool t;
}p[maxn];
struct item{
bool t; int c;
}t[maxn];
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++) cin>>p[i].t>>p[i].name;
for(int i=1;i<=m;i++) cin>>t[i].t>>t[i].c;
for(int i=1;i<=m;i++){
if(p[now].t+t[i].t==1) turn=1; else turn=-1;
now+=turn*t[i].c+n; now%=n;
}
cout<<p[now].name;
return 0;
}