QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#371722 | #6748. Spin the Wheel | swimseal | WA | 1ms | 3628kb | C++14 | 1.0kb | 2024-03-30 15:11:57 | 2024-03-30 15:11:58 |
Judging History
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'