inlineintgetint(){ int s = 0, x = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') x = -1; ch = getchar(); } while (isdigit(ch)) { s = s * 10 + ch - '0'; ch = getchar(); } return s * x; }
inlinevoidputint(int x, bool returnValue){ if (x < 0) { x = -x; putchar('-'); } if (x >= 10) putint(x / 10, false); putchar(x % 10 + '0'); if (returnValue) putchar('\n'); }
intmain(int argc, char *const argv[]){ n = getint(), m = getint(); for (int i = 1; i <= n; ++i) { int to; cin >> to; string name; cin >> name; t[i].faceTo = (to == 1 ? true : false); t[i].name = name; } int now = 1; for (int i = 1; i <= m; ++i) { int tA = getint(); bool right = tA == 1 ? true : false; // true 表示在右边 // false 表示在左边 int s = getint(); if (right) { if (t[now].faceTo == true) now -= s; else now += s; } else { if (t[now].faceTo == true) now += s; else now -= s; } if (now > n) now -= n; if (now < 1) { int moved = 1 - now; now = n + 1 - moved; } } cout << t[now].name << endl; return0; }