题目原文请移步下面的链接
模拟
普及-
#include <bits/stdc++.h>
using namespace std;
#define endl '\n';
struct edge {
string s;
bool b;
};
int instruct(bool x, bool y, int z) {
if (x ^ y) {
return z;
} else {
return -z;
}
}
void best_coder() {
int n, m;
cin >> n >> m;
vector<edge> v(n);
for (int i = 0; i < n; ++i) {
cin >> v[i].b >> v[i].s;
}
int t = 0;
int x, y;
for (int i = 0; i < m; ++i) {
cin >> x >> y;
t += instruct(v[t].b, x, y);
if (t <= 0) {
t += n;
}
if (t >= n) {
t %= n;
}
}
cout << v[t].s;
}
void happy_coder() {
}
int main() {
// 提升cin、cout效率
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
// 小码匠
best_coder();
// 最优解
// happy_coder();
// 返回
return 0;
}
END