| 比赛 |
csp2025模拟练习2 |
评测结果 |
AAAAAAAAAAAAAAAAAAAA |
| 题目名称 |
玩具谜题 |
最终得分 |
100 |
| 用户昵称 |
我常常追忆未来 |
运行时间 |
1.048 s |
| 代码语言 |
C++ |
内存使用 |
41.84 MiB |
| 提交时间 |
2025-10-29 10:59:03 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+7;
struct node{
int dis;
string name;
}a[N];
int n,m;
int main(){
freopen("toya.in","r",stdin);
freopen("toya.out","w",stdout);
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i].dis>>a[i].name;
}
int now=1;
for(int i=1;i<=m;i++){
int op,x;
cin>>op>>x;
if(op==0){
if(a[now].dis==0){
now=(now-x+n)%n;
}
else{
now=(now+x)%n;
}
}
else{
if(a[now].dis==0){
now=(now+x)%n;
}
else{
now=(now-x+n)%n;
}
}
if(now==0){
now=n;
}
}
cout<<a[now].name;
return 0;
}