@[ly202303](/user/1185854) 请用markdown
by Special_Tony @ 2024-01-05 20:51:51
```
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
long long n,m,fx[N];
string name[N];
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
cin>>fx[i]>>name[i];
}
int j=1,a,s;
for(int o=1;o<=m;o++){
cin>>a>>s;
if(a==1){
if(fx[j]==1) j-=s;
if(fx[j]==0) j+=s;
}
else if(a==0){
if(fx[j]==1) j+=s;
if(fx[j]==0) j-=s;
}
while(j<0) j+=n;
if(j>n) j%=n;
}
cout<<name[j];
return 0;
}
```
by danlao @ 2024-01-05 21:06:13
帮你改一下markdown
by danlao @ 2024-01-05 21:07:48
@[sz_mane](/user/743373) 好的,第一次求助,没排版
by ly_magician @ 2024-01-05 21:10:09
@[sz_mane](/user/743373) 你这个主页………………
by ly_magician @ 2024-01-05 21:12:44
@[ly202303](/user/1185854)
```cpp
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
long long n,m,fx[N];
string name[N];
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
cin>>fx[i]>>name[i];
}
int j=1,a,s;
for(int o=1;o<=m;o++){
cin>>a>>s;
if(a==1){
if(fx[j]==1) j-=s;
else if(fx[j]==0) j+=s;// 第一个错误的点,这里不加else执行完上面的j-=s后,j值改变再执行一遍j+=s
}
else if(a==0){
if(fx[j]==1) j+=s;
else if(fx[j]==0) j-=s;//同上
}
while(j<=0) j+=n;//要取等
if(j>n) j%=n;
}
cout<<name[j];
return 0;
}
```
by sdyzpf @ 2024-01-05 21:22:15
@[sdyzpf](/user/174477) 感谢至极
by ly_magician @ 2024-01-13 14:09:07