| 比赛 |
csp2025模拟练习2 |
评测结果 |
AAAAAAAAAAAAAAAAAAAA |
| 题目名称 |
玩具谜题 |
最终得分 |
100 |
| 用户昵称 |
淮淮清子 |
运行时间 |
0.298 s |
| 代码语言 |
C++ |
内存使用 |
7.54 MiB |
| 提交时间 |
2025-10-29 08:27:26 |
显示代码纯文本
#include<iostream>
#include<stack>
using namespace std;
const int MAXN = 1e5 + 5;
struct node{
int h;
string name;
}p[MAXN];
stack<int> a;
int n, m, x, y;
int main(){
freopen("toya.in", "r", stdin);
freopen("toya.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(int i = 0;i < n;i ++){
cin >> p[i].h >> p[i].name;
}
a.push(0);
for(int i = 1;i <= m;i ++){
cin >> x >> y;
if(p[a.top()].h == 0 && x == 0) a.push((a.top() + n - y) % n);
else if(p[a.top()].h == 0 && x == 1) a.push((a.top() + y) % n);
else if(p[a.top()].h == 1 && x == 0) a.push((a.top() + y) % n);
else if(p[a.top()].h == 1 && x == 1) a.push((a.top() + n - y) % n);
}
cout << p[a.top()].name << '\n';
return 0;
}