50分怎么回事
查看原帖
50分怎么回事
92287
冬瓜皮楼主2018/10/14 23:15

果然颓了,水题也写不对 没有TLE,一半WA很迷

#include<iostream>
using namespace std;
struct toys{
	int direction;
	string name;
};
toys t[100002];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>t[i].direction>>t[i].name;
	}
	int now=1;
	int lr,steps;
	for(int i=0;i<m;i++){
		cin>>lr>>steps;
		if(t[now].direction==0&&lr==1){
			now+=steps;
			if(now>n)	now%=n;
		}
		if(t[now].direction==0&&lr==0){
			if(now>steps)	now-=steps;
			else now=n-(steps-now);
		}
		if(t[now].direction==1&&lr==0){
			now+=steps;
			if(now>n)	now%=n;
		}
		if(t[now].direction==1&&lr==0){
			if(now>steps)	now-=steps;
			else now=n-(steps-now);
		}
	}
	cout<<t[now].name;
	return 0;
}
2018/10/14 23:15
加载中...