QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#383887 | #6748. Spin the Wheel | touzi# | WA | 18ms | 5260kb | C++17 | 1.6kb | 2024-04-09 18:31:25 | 2024-04-09 18:31:26 |
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];
}
for (int i = 0; i < n; i++)
{
if (a[i] == 0)
{
mk = i;
break;
}
}
ll cnt = 0;
for (int i = 0; i < n; i++)
{
if (a[i] < a[(i + 1)%n])
{
sum = a[(i + 1)%n] - a[i];
if (cnt == 0)
{
cnt == sum;
}
else
{
if (cnt != sum)
{
cout << "-1\n";
return 0;
}
}
}
}
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 = 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;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3580kb
input:
5 1 3 0 2 4
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 18ms
memory: 5260kb
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:
55555
result:
ok 1 number(s): "55555"
Test #3:
score: 0
Accepted
time: 14ms
memory: 5208kb
input:
100000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 500...
output:
50000
result:
ok 1 number(s): "50000"
Test #4:
score: -100
Wrong Answer
time: 17ms
memory: 5248kb
input:
100000 1 401 801 1201 1601 2001 2401 2801 3201 3601 4001 4401 4801 5201 5601 6001 6401 6801 7201 7601 8001 8401 8801 9201 9601 10001 10401 10801 11201 11601 12001 12401 12801 13201 13601 14001 14401 14801 15201 15601 16001 16401 16801 17201 17601 18001 18401 18801 19201 19601 20001 20401 20801 21201...
output:
-1
result:
wrong answer 1st numbers differ - expected: '401', found: '-1'