QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#385236 | #6748. Spin the Wheel | zy123 | WA | 17ms | 9740kb | C++14 | 2.6kb | 2024-04-10 16:49:52 | 2024-04-10 16:49:53 |
Judging History
answer
#include<iostream>
#include<map>
#include<set>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<stack>
#include<stdint.h>
#include<bitset>
#include<fstream>
#include<time.h>
#define IOS cin.tie(0) -> sync_with_stdio(false), cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e6+5;
const int M=1e6+5;
const int inf=0x3f;
#define lc p<<1
#define rc p<<1|1
#define endl "\n"
double pai = acos(-1);
ll mod=1e9+7;
inline ll read()
{
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
return x*f;
}
//__int128 read_128()//c++20(64)可用
//{
// __int128 x=0,f=1;char ch = getchar();
// while(ch < '0' || ch > '9'){if(ch == '-') f=-1;ch=getchar();}
// while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch=getchar();}
// return x*f;
//}
//void print_128(__int128 x)
//{
// if(x<0){putchar('-');x=-x;}
// if(x>9)print_128(x/10);
// putchar(x % 10 + '0');
//}
int idx=1,nxt[M*2],dian[M*2],h[N];
ll quan[M*2];
//ll rong[M*2];
void add(int a,int b,ll c)
{
dian[++idx]=b;
quan[idx]=c;
//rong[idx]=c;
nxt[idx]=h[a];
h[a]=idx;
}
//ll ksm(ll a,ll b){ll sum=1;while(b){if(b&1){sum*=a;}a*=a;b>>=1;}return sum;}
//ll ksm_mod(ll a,ll b,ll p){ll sum=1;while(b){if(b&1){sum*=a;sum%=p;}a*=a;a%=p;b>>=1;}return sum%p;}
//ll gsc(ll a,ll b,ll p){ll sum=0;while(b){if(b&1){sum+=a;sum%=p;}a=a*2;a%=p;b/=2;}return sum%p;}
int n;
ll a[N];
ll b[N];
int main()
{
cin >> n;
ll ans=0;
ll mk=-1;
for(int i=0;i<n;i++)
{
cin >> a[i];
if(a[i]==0)
{
ans++;
}
if(a[i]==0&&mk==-1)
{
mk=i;
}
}
if(ans==n)
{
cout << "0\n";
return 0;
}
if(ans==0)
{
cout << "-1\n";
return 0;
}
b[0]=a[0];
ll x=a[1]-a[0];
if(a[1]<a[0])
{
x=a[1]+n-a[0];
x%=n;
}
for(ll i=1;i<n;i++)
{
b[i]=i*x+b[0];
b[i]=(b[i]%n+n)%n;
}
bool fl=0;
for(int i=0;i<n;i++)
{
//cout << a[i] << " " << b[i] << endl;
if(a[i]!=b[i])
{
fl=1;
break;
}
}
if(fl)
{
cout << "-1\n";
return 0;
}
if(a[0]==0)
{
cout << x << endl;
}
else
{
cout << x+1 << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7752kb
input:
5 1 3 0 2 4
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 17ms
memory: 8472kb
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: 6ms
memory: 8552kb
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: 16ms
memory: 9740kb
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'