0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-20 16:45:24 +00:00
OI-codes/Luogu/P1563/P1563.cpp

39 lines
832 B
C++
Raw Normal View History

2020-09-24 10:35:01 +00:00
// R38818598
#include <bits/stdc++.h>
using namespace std;
struct node {
string name;
2021-11-19 09:01:13 +00:00
bool towards;
2020-09-24 10:35:01 +00:00
};
int main() {
// freopen("data/P1563_sample1.in", "r", stdin);
2021-11-19 09:01:13 +00:00
int n, m, now = 0, x, y;
2020-09-24 10:35:01 +00:00
node a[100005];
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> a[i].towards >> a[i].name;
}
for (int i = 0; i < m; i++) {
cin >> x >> y;
if (a[now].towards == 0) {
if (x == 0) {
now = (now + n - y) % n;
2021-11-19 09:01:13 +00:00
} else if (x == 1) {
2020-09-24 10:35:01 +00:00
now = (now + y) % n;
}
2021-11-19 09:01:13 +00:00
} else if (a[now].towards == 1) {
2020-09-24 10:35:01 +00:00
if (x == 0) {
now = (now + y) % n;
2021-11-19 09:01:13 +00:00
} else if (x == 1) {
2020-09-24 10:35:01 +00:00
now = (now + n - y) % n;
}
}
}
cout << a[now].name << endl;
return 0;
}