求助,为什么值得了90分?
查看原帖
求助,为什么值得了90分?
542705
andygao楼主2022/8/1 15:46

请问为什么只得了90分?

#include <bits/stdc++.h>
using namespace std;
int n,m,temp = 1;
struct t{
	int cx;
	string zy;
}toy[100009];
int b(int x,int y,int temp){
	if(toy[temp].cx==0){
		if(x==0){
			temp = (temp-y+n)%n;
		}else{
			temp += y;
			temp %= n;
		}
	}else{
		if(x==0){
			temp += y;
			temp %= n;
		}else{
			temp = (temp-y+n)%n;
		}
	}
	return temp;
	//cout<<temp<<'\n';
}
int main(){
	cin>>n>>m;
	for(int i = 1;i<=n;i++){
		cin>>toy[i].cx>>toy[i].zy;
	}
	for(int i = 1;i<=m;i++){
		int a,s;
		cin>>a>>s;
		temp = b(a,s,temp);
	}
	//cout<<temp<<'\n';
	cout<<toy[temp].zy;
}
2022/8/1 15:46
加载中...