求教,为什么测试点9,10,11,13Runtime error呀
查看原帖
求教,为什么测试点9,10,11,13Runtime error呀
306616
Lancelot144楼主2021/1/8 16:26

代码如下:

#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>

using namespace std;

long n,m,x,y;

class Person
{
public:
	string name;
	long state;
}p[10010];

int main() {
	cin >> n >> m;
	for (long i = 0; i < n; ++i) {
		cin >> p[i].state >> p[i].name;
	}
	long temp = 0;
	for (long i = 1; i <= m; ++i) {
		cin >> x >> y;
		if (p[temp].state == 0 && x == 0)
		{
			temp = (temp - y + n) % n;
		}
		else if (p[temp].state == 0 && x == 1)
		{
			temp = (temp + y) % n;
		}
			
		else if (p[temp].state == 1 && x == 1)
		{
			temp = (temp - y + n) % n;
		}
		else if (p[temp].state == 1 && x == 0)
		{
			temp = (temp + y) % n;
		}
	}
	cout << p[temp].name << endl;

	system("pause");
	return 0;
}
2021/1/8 16:26
加载中...