求助,麻烦大佬帮忙看一下为什么只有70分..
查看原帖
求助,麻烦大佬帮忙看一下为什么只有70分..
324176
yuyuyuyu12345楼主2022/9/2 17:47
#include <iostream>
#include <cstring>
using namespace std;
struct ren{
	char a[1000];
	int n;
};
int main()
{
	int n,m;
	struct ren stu[2000];
	cin>>n>>m;
	int x,y;
	int k=0;
	for(int i=0;i<n;i++) cin>>stu[i].n>>stu[i].a;
	for(int i=0;i<m;i++)
	{
		cin>>x>>y;
		if(x==0&&stu[k].n==0||x==1&&stu[k].n==1)//顺时针 
		{
			if(k-y<0)
			k=n+k-y;
			else k=k-y;
		}
		else if(x==0&&stu[k].n==1||x==1&&stu[k].n==0)//逆时针 
		{
			if(k+y>n) k=k+y-n;
			else k=k+y;
		}
	}
	cout<<stu[k].a;
}
2022/9/2 17:47
加载中...