代码如下,样例只有第八个过不去:
#include <iostream>
#include <cstdio>
using namespace std;
const int N = 100010;
int st[N];
int n, m;
char str[N][15];
int main()
{
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i ++ ) scanf("%d%s", &st[i], str[i]);
int ans = 1;
int rnd, stp;
while (m -- )
{
scanf("%d%d", &rnd, &stp);
if (!st[ans])//朝内
{
if (!rnd)
ans = ans == stp ? n : (ans + n - stp) % n;
else ans = (ans + stp) % n;
}
else
{
if (!rnd)
ans = (ans + stp) % n;
else ans = ans == stp ? n : (ans + n - stp) % n;
}
}
printf("%s\n", str[ans]);
return 0;
}