80分,9. 10. 11. 13不过,求大佬帮助
查看原帖
80分,9. 10. 11. 13不过,求大佬帮助
339826
BlackJiang楼主2020/5/28 22:33
#include<iostream>

using namespace std;

int main()
{
	int direction[10000];
	char name[100000][11];
	int n, m;//n:小人个数 m:指令个数
	int a, s;//a: 左右方向 s:左右距离
	int i;
	int position;
	
	position = 0;
	cin >> n >> m;
	for(i = 0; i < n; i++)
	{
		cin >> direction[i] >> name[i];
	}
	for(i = 0; i < m; i++)
	{
		cin >> a >> s;
		if(direction[position] + a == 1)
		{
			position = (position + s) % n;
		}
		else
		{
			position = (position - s + n) % n;
		}
	}
	cout << name[position] << endl;
}
2020/5/28 22:33
加载中...