QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#384337#6748. Spin the WheelfzxWA 1ms7820kbC++141.0kb2024-04-09 22:08:402024-04-09 22:08:40

Judging History

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

  • [2024-04-09 22:08:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7820kb
  • [2024-04-09 22:08:40]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long 
using namespace std;
const int INF=2e5+5;
int n,a[INF],b[INF],cc[INF],ba2[INF];
int ksm(int x,int y,int Mod) {
	int ba=x%Mod,ans=1;
	while (y) {
		if (y&1) ans=(ans*ba)%Mod;
		ba=(ba*ba)%Mod;y>>=1;
	}
	return ans;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i]; 
	int res=1e18,fl=0;;
	for (int i=0;i<n;i++) 
		if (i*a[1]%n!=a[i]) fl=1;
	if (!fl) res=min(res,a[1]);
	for (int i=0;i<n;i++) b[i]=a[i]-i,b[i]%=n,b[i]+=n,b[i]%=n;
	for (int i=0;i<n;i++) b[i+n]=b[i];
	int ba=191,sum=0;
	for (int i=0;i<n;i++) sum=(sum*ba+i)%n;
	for (int i=0;i<n+n;i++) cc[i]=(cc[i-1]*ba+b[i])%n;
	ba2[0]=1;
	for (int i=1;i<=n+n;i++) ba2[i]=ba2[i-1]*ba%n;
	int Mod=n;
	for (int y=1;y<n;y++) {
//		int fl=0;
//		for (int i=0;i<n;i++)
//			if (b[1+y]*i%n!=b[i+y]) fl=1;
//		if (!fl) res=min(res,b[1+y]+2);
		
		if (b[1+y]*sum%Mod==((cc[n-1+y]-cc[0+y-1]*ba2[n])%Mod+Mod)%Mod)
			res=min(res,b[1+y]+2);
	}
	if (res>1e9) cout<<"-1\n";
	else cout<<res<<"\n";
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7820kb

input:

5
1 3 0 2 4

output:

2

result:

wrong answer 1st numbers differ - expected: '3', found: '2'