QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#371722#6748. Spin the WheelswimsealWA 1ms3628kbC++141.0kb2024-03-30 15:11:572024-03-30 15:11:58

Judging History

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

  • [2024-03-30 15:11:58]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3628kb
  • [2024-03-30 15:11:57]
  • 提交

answer

#include <bits/stdc++.h>

#define x first
#define y second
#define pb push_back 
#define int long long

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
 
const int N = 2e6 + 10;
const double eps = 1e-9;

int n;
int a[N];
void solve(){
	cin >> n;
	int maxv = 0, minn = 1e8;
	for (int i = 0; i < n ; i ++){
		cin >> a[i];
		a[i + n] = a[i];
		maxv = max(a[i], maxv);
		minn = min(a[i], minn);
	}
	if(maxv == minn){
		if(minn == 0){
			cout << 0 << endl;
		}
		else if(minn == n - 1 && n % 2 == 0){
			cout << n << endl;
		}
		else puts("-1");
		return;
	}
	if(minn != 0){
		puts("-1");
		return;
	}
	int id = 0;
	while(a[id] != 0) id ++;
	int cnt = a[id + 1];
	//6cout << a[id + 1] << endl;

	for (int i = id,t = 0; i < id + n; i ++,t ++){
		if(a[i] = (1ll* t * cnt) % n){
			puts("-1");
			return;
		}	
	}
	if(id != 0) cnt ++;
	cout << cnt << endl;

	
}

signed main(){
	int t = 1;// cin >>t;
	while(t --) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
1 3 0 2 4

output:

-1

result:

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