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 "gondola.h"
#include <bits/stdc++.h>
int ch[250005],i;
int valid(int n, int inputSeq[])
{
int ST=-1,st,C=1;
for(i=0;i<n;i++)ch[i]=0;
for(i=0;i<n;i++)
{
if(ch[inputSeq[i]]==1){C=0;break;}
ch[inputSeq[i]]=1;
}
for(i=0;i<n;i++)
{
if(inputSeq[i]<=n)
{
st=i-inputSeq[i]+1;st=(st+n)%n;
if(ST==-1)ST=st;
else if(ST!=st){C=0;break;}
}
}
return C;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int ST=-1,m=-1,ba,sz=0;
for(i=1;i<=250000;i++)ch[i]=-1;
for(i=0;i<n;i++)
{
m=std::max(gondolaSeq[i],m);
ch[gondolaSeq[i]]=i;
if(gondolaSeq[i]<=n)ST=(i-gondolaSeq[i]+1+n)%n;
}
if(ST==-1)ST=0;
ba=n;
for(i=n+1;i<=m;i++)
{
if(ch[i]>=0)
{
replacementSeq[sz++]=(ch[i]-ST+n)%n+1;
for(int j=ba;j<i;j++)
{
replacementSeq[sz++]=j;
}
ba=i;
}
}
return m-n;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |