QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#383844 | #6748. Spin the Wheel | touzi# | WA | 10ms | 8244kb | C++17 | 2.7kb | 2024-04-09 18:05:28 | 2024-04-09 18:05:28 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS
////#pragma GCC optimize(1)
////#pragma GCC optimize(2)
////#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
using namespace std;
#define N 2000005
#define M 1331
#define PII pair<int,int>
#define PIII pair<pair<int,int>,int>
#define VPII vector<PII>
#define VPIII vector<PIII>
#define endl "\n"
#define inf 0x3f3f3f3f3f3f
#define ll long long
#define ull unsigned long long
const double eps = 1e-6;
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define mod 998244353
ll n, m,k;
ll a[N];
ll b[N];
int main()
{
cin >> n;
ll sum = 0;
ll mk = 0;
for (int i = 0; i < n; i++)
{
cin >> a[i];
if (a[i] == 0)
{
mk = i;
}
}
if (n == 2 && a[0] == 1 && a[1] == 1)
{
cout << 3 << "\n";
return 0;
}
for (int i = 0; i < n; i++)
{
if (a[i] < a[(i + 1)%n])
{
sum = a[(i + 1)%n] - a[i];
break;
}
}
for (ll i = 0; i < n; i++)
{
b[i] = sum * i;
b[i] %= n;
}
int ans = 0;
for (int i = 0; i < n; i++)
{
if (a[i] == 0)
{
ans++;
}
}
if (ans == n)
{
cout << "0\n";
return 0;
}
ans = 0;
int as = 0;
as = mk;
for (int i = 0; i < n; i++)
{
if (a[mk % n] == b[i])
{
ans++;
mk++;
}
else
{
ans = -1;
break;
}
}
if (ans == -1)
{
cout << ans << "\n";
return 0;
}
if (as == 0)
{
cout << sum << "\n";
}
else
{
cout << sum + 1 << "\n";
}
return 0;
}
//#define _CRT_SECURE_NO_WARNINGS
//////#pragma GCC optimize(1)
//////#pragma GCC optimize(2)
//////#pragma GCC optimize(3,"Ofast","inline")
//#include<bits/stdc++.h>
//using namespace std;
//#define N 2000005
//#define M 1331
//#define PII pair<int,int>
//#define PIII pair<pair<int,int>,int>
//#define VPII vector<PII>
//#define VPIII vector<PIII>
//#define endl "\n"
//#define inf 0x3f3f3f3f3f3f
//#define ll long long
//#define ull unsigned long long
//const double eps = 1e-6;
//#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//#define mod 998244353
//ll n, m, k;
//ll ans[N], ww[10000500];
//int main() {
// IOS;
// cin >> n;
// ll s1 = 1;
// for (ll i = 1; i <= n; i++) {
// s1 = s1 * i % mod;
// ww[i] = s1 % mod;
// }
// ans[1] = 1, ans[2] = 1, ans[3] = 3, ans[4] = 10;
// if (n <= 4) cout << ans[n] % mod;
// else {
// ll sum = (n - 2) * ww[n - 2] + (n - 3) * ww[n - 2] - 2 + (n - 4) * ww[n - 2] - 6 * (n - 4) * ww[n - 4];
// sum %= mod;
// for (int i = 5; i < n - 1; i++) {
// ll ssr = (2*(n-i-1)%mod+(n-i-1)*(n-i-2)/2%mod)*ww[n-3] % mod;
// sum = (sum + ssr) % mod;
// }
// sum = (sum + ww[n - 1]) % mod;
// cout << sum;
// }
// return 0;
//}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5684kb
input:
5 1 3 0 2 4
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: -100
Wrong Answer
time: 10ms
memory: 8244kb
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:
55556
result:
wrong answer 1st numbers differ - expected: '55555', found: '55556'