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 <algorithm>
#include <cstring>
#include <vector>
#include <cstdio>
#include "gondola.h"
using namespace std;
int valid(int n, int inputSeq[]){
bool x[250010];
memset(x,sizeof(x),0);
int firstoffset=-1;
for(int i=0;i<n;i++){
if(inputSeq[i]<=n){
if(firstoffset==-1)
firstoffset=(inputSeq[i]-i+n)%n;
else
if(firstoffset!=(inputSeq[i]-i+n)%n)
return 0;
}
if(x[inputSeq[i]]) return 0;
x[inputSeq[i]]=true;
}
return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
vector<pair<int,int> > X;
int firstoffset=0;
for(int i=0;i<n;i++){
if(gondolaSeq[i]<=n){
if(firstoffset==0)
firstoffset=(gondolaSeq[i]-i+n)%n;
}
}
for(int i=0;i<n;i++){
if(gondolaSeq[i]>n){
X.push_back(make_pair(gondolaSeq[i],i));
}
}
sort(X.begin(),X.end());
int ptr=0;
int top=n+1;
for(int i=0;i<X.size();i++){
//printf("%d %d\n",X[i].second,firstoffset);
replacementSeq[ptr++]=(X[i].second+firstoffset+n-1)%n+1;
for(int j=top;j<X[i].first;j++)
replacementSeq[ptr++]=j;
top=X[i].first+1;
}
return ptr;
}
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... |