请大家帮忙看看
查看原帖
请大家帮忙看看
91975
GVNDN楼主2020/5/24 20:41
#include<iostream>
#include<string>
using namespace std;

struct toy
{
	int dir;    //dir是人面向的方向
	string job;    //人的身份
} toys[100000 + 10];
	
int main()
{
	int n, o, index = 1;    //n是人数,o是命令数,index是当前下标
	cin >> n >> o;
	for(int i = 1; i <= n; i++)
		cin >> toys[i].dir >> toys[i].job;
	while(o--)
	{
		int dir, dist;    //这个dir是命令方向,dist是命令距离(几个人)
		cin >> dir >> dist;
		if(dir == 0)
		{
			if(toys[index].dir == 1)
				index = (index + dist) % n;
			else
				index = (index - dist + n) % n;
		}
		else if(dir == 1)
		{
			if(toys[index].dir == 1)
				index = (index - dist + n) % n;
			else
				index = (index + dist) % n;
		}
	}
	cout << toys[index].job << endl;
	return 0;
}

第四号和第八号测试点WA,其余都AC。(今天没有下载次数了,就来求助下大家,谢谢!) (另:提问若有不妥当的地方,请大家指出)

2020/5/24 20:41
加载中...