蒟蒻求助(为什么用这种if形式过不了)
查看原帖
蒟蒻求助(为什么用这种if形式过不了)
612072
CarpeDiem03楼主2023/2/6 18:54
#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>

using namespace std;

const int N = 100010;

int n, m;

struct People
{
	int direct;
	string name;
}people[N];

int main()
{
	cin >> n >> m;

	for (int i = 1; i <= n; i++)
	{
		cin >> people[i].direct >> people[i].name;
	}

	int who = 1;

	for (int i = 0; i < m; i++)
	{
		int zy, len;
		cin >> zy >> len;
	
		if (zy == 1 && people[who].direct == 0)
		{
			who += len;
			if (who > n)
			{
				who -= n;
			}
		}
		if (zy == 1 && people[who].direct == 1)
		{
			who -= len;
			if (who < 1)
			{
				who += n;
			}
		}
		if (zy == 0 && people[who].direct == 0)
		{
			who -= len;
			if (who < 1)
			{
				who += n;
			}
		}
		if (zy == 0 && people[who].direct == 1)
		{
			who += len;
			if (who > n)
			{
				who -= n;
			}
		}
	}

	cout << people[who].name;

	return 0;
}
2023/2/6 18:54
加载中...