# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
320129 | lukameladze | Gondola (IOI14_gondola) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
# include <bits/stdc++.h>
using namespace std;
long long n,a[300005],x,num,idx,mp[300005];
int valid(int n , int a[])
{
//cin>>n;
idx=-1;
for (int i=0; i<n; i++)
{
// cin>>a[i];
if (mp[a[i]]) x=1;
mp[a[i]]=1;
if (a[i]<=n) idx=i;
}
if (x==1)
{
return 0;
}
if (!idx)
{
return 1;
}
num=a[idx];
for (int i=idx+1; i<n; i++)
{
num++;
if (num==n+1) num=1;
// cout<<a[i]<<" "<<num<<endl;
if (a[i]<=n && a[i]!=num)
{
return 0;
}
}
// cout<<num<<endl;
for (int i=0; i<idx; i++)
{
num++;
if (num==n+1) num=1;
if (a[i]<=n && a[i]!=num)
{
return 0;
}
}
return 0;
}