链接:Miku

暴力模拟

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
int n,m;
int ma[100001];
map <int,string> pl;
string s;
int f;
int x,y;
int id=1;
void sh(int st){
	if(st+id>n)
	id=st+id-n;
	else
	id=st+id; 
} 
void ni(int st){
	if(st>=id)
	id=n-(st-id);
	else{
		id=id-st;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i){
		scanf("%d",&f);
		cin>>s;
		ma[i]=f;
		pl[i]=s;
	} 
	for(int i=1;i<=m;++i){
		scanf("%d%d",&x,&y);
		if(ma[id]){
			if(x)
			ni(y);
			else
			sh(y) ;
		}else{
			if(x)
			sh(y);
			else
			ni(y);
		} 
	}
	cout<<pl[id];
	return 0;
}

相关文章:

  • 2021-10-04
  • 2021-10-26
  • 2021-08-19
  • 2022-01-18
  • 2022-02-16
  • 2022-12-23
  • 2021-07-25
猜你喜欢
  • 2021-08-12
  • 2021-11-24
  • 2021-07-08
  • 2021-07-27
  • 2021-10-24
  • 2022-02-11
  • 2021-12-23
相关资源
相似解决方案