QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#383841 | #6736. Alice and Bob | touzi# | WA | 0ms | 3636kb | C++17 | 2.7kb | 2024-04-09 18:04:06 | 2024-04-09 18:04:07 |
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: 0
Wrong Answer
time: 0ms
memory: 3636kb
input:
1
output:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'