QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#384329#6748. Spin the WheelfzxTL 0ms3732kbC++14618b2024-04-09 21:57:192024-04-09 21:57:20

Judging History

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

  • [2024-04-09 21:57:20]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3732kb
  • [2024-04-09 21:57:19]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long 
using namespace std;
const int INF=2e5+5;
int n,a[INF],b[INF];
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];
	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 (res>1e9) cout<<"-1\n";
	else cout<<res<<"\n";
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3732kb

input:

5
1 3 0 2 4

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: -100
Time Limit Exceeded

input:

100000
0 55555 11110 66665 22220 77775 33330 88885 44440 99995 55550 11105 66660 22215 77770 33325 88880 44435 99990 55545 11100 66655 22210 77765 33320 88875 44430 99985 55540 11095 66650 22205 77760 33315 88870 44425 99980 55535 11090 66645 22200 77755 33310 88865 44420 99975 55530 11085 66640 221...

output:


result: