【 NOIP 2016 】【 玩具谜题 】

luogu 传送门

当然 水题 自然好想,我这种蒟蒻看完题就想完了,

然鹅,第一次提交 并没有AC 因为% 只取 0 ~ n-1  ,我是从 1 开始存的,当然 GG了 , 我还是太菜了吗

怪自己太大意,为什么就不想试别的数据呢? 记个教训在这儿 ______________

NOIP 临近, 加油啊 

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

inline int wread(){
	char c(getchar ());int wans(0),flag(1);
	while (c<'0' || c>'9'){if (c=='-') flag=-1; c=getchar();}
	while (c>='0' && c<='9'){wans=wans*10+c-'0';c=getchar();}
	return wans*=flag;
}

int n,m;
struct node{bool dir; char name_p[20];}e[100006];

int main (){
	n=wread();m=wread();
	for (int i(0);i<n;++i){
		//0->内  1->外
		int t;
		scanf ("%d",&t);
		e[i].dir=t;
		scanf ("%s",e[i].name_p);
	}
	int now=0;
	while (m--){
		int pos=wread(),num=wread();
		if (e[now].dir==0){
			if (pos==0){
				now+=n;
				now-=num;
				now%=n;
			}
			else {
				now+=num;
				now%=n;
			}
		}
		else {
			if (pos==0){
				now+=num;
				now%=n;
			}
			else {
				now+=n;
				now-=num;		
				now%=n;
			}
		}
	}
	printf("%s\n",e[now].name_p);
	return 0;
}

猜你喜欢

转载自blog.csdn.net/violinlove/article/details/81389710