P1563 玩具谜题

链接: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;
}
posted @ 2020-09-04 21:02  Simex  阅读(87)  评论(0编辑  收藏  举报