逻辑有一些复杂,但是理解之后就很简单。题目描述中mogician什么的太暴力了。。。-1s
按照题目描述模拟,就能满分。
/* Au: GG
* CCF NOIP2016 day1
* toy
*/ #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std; int n, m, cmd1, cmd2, pt;
struct toy {
bool d;
char p[];
};
toy f[ + ]; //存玩具小人 int cshun(int pn, int num) {
pn -= num;
if (pn < ) pn += n;
return pn;
} int cni(int pn, int num) {
pn += num;
if (pn > n) pn -= n;
return pn;
} int main() {
scanf("%d%d", &n, &m);
int tmp;
for (int k = ; k <= n; k++) {
scanf("%d %s", &tmp, &f[k].p);
f[k].d = tmp;
} pt = ;
for (int k = ; k <= m; k++) {
scanf("%d%d", &cmd1, &cmd2); if (f[pt].d) { //1-> direction outside
if (cmd1) pt = cshun(pt, cmd2); //right hand
else pt = cni(pt, cmd2); //left hand
} else { //0-> direction inside
if (cmd1) pt = cni(pt, cmd2); //right hand
else pt = cshun(pt, cmd2); //left hand
} } printf("%s", f[pt].p);
return ;
}