QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#413530#6748. Spin the WheelxiaohongRE 0ms0kbC++20680b2024-05-17 17:54:062024-05-17 17:54:07

Judging History

你现在查看的是最新测评结果

  • [2024-05-17 17:54:07]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-05-17 17:54:06]
  • 提交

answer

#include<bits/stdc++.h>
#define IOS cin.tie(0),cout.tie(0),ios::sync_with_stdio(0)
#define int long long
using namespace std;
const int mod=998244353;
int a[100005];
void solve()
{
	int n;
	cin>>n;
	for(int t=1;t<=n;t++)
	{
		cin>>a[t];
	}
	int f=0;
	for(int t=1;t<n;t++)
	{
		if((a[t]-a[t+1]+n)%n!=(a[2]-a[1]+n)%n)
		{
			f=1;break;
		}
	}
	if(f==1)
	{
		cout<<"-1\n";return;
	}
	int d=(a[2]-a[1]+n)%n;
	if(d==0)
	{
		if(a[1]==0) cout<<"0\n";
		else cout<<n+1<<endl;
	}
	else
	{
		if(a[1]==0) cout<<d<<endl;
		else cout<<d+1<<endl;
	}
}
signed main()
{
    IOS;
	int T=1;
    cin>>T;
    while(T--)
        solve();
    return 0;
}

详细

Test #1:

score: 0
Runtime Error

input:

5
1 3 0 2 4

output:

2

result: