QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#411949 | #6748. Spin the Wheel | xiaodaiyang# | WA | 0ms | 3868kb | C++14 | 1.1kb | 2024-05-15 22:05:37 | 2024-05-15 22:05:38 |
Judging History
answer
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast,unroll-loops")
using namespace std;
using i64 = long long;
using i128 = __int128;
using ui64 = unsigned long long;
using ui32 = unsigned int;
#define x first
#define y second
typedef pair<i64, i64> PII;
constexpr int mod = 998244353;
constexpr int N = 1e6 + 10, M = 2e6 + 10;
void slove() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int c = -1;
for (int i = 0; i < n; i++) {
// cout << ((a[i] - a[((i - 1) + n) % n]) % n + n) % n << "!\n";
if (c == -1 || c == ((a[i] - a[((i - 1) + n) % n]) % n + n) % n) {
c = ((a[i] - a[((i - 1) + n) % n]) % n + n) % n;
}
else {
cout << "-1\n";
return;
}
}
if (c == 0) {
cout << 2 * n - 1 << '\n';
}
else cout << c * 2 - 1 << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t = 1;
cin >> t;
while (t--) {
slove();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3868kb
input:
5 1 3 0 2 4
output:
1 -3 3 3 3
result:
wrong answer 1st numbers differ - expected: '3', found: '1'