# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1025419 | vjudge1 | Gondola (IOI14_gondola) | C++17 | 33 ms | 5204 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 "gondola.h"
#include<bits/stdc++.h>
using namespace std;
int valid(int n, int inputSeq[]) {
int PS=-1;
set<int>st;
for(int i=0;i<n;i++){
st.insert(inputSeq[i]);
if(inputSeq[i]>n)
continue;
int k=n+i-inputSeq[i];
k%=n;
if(PS==-1)
PS=k;
if(PS-k)
return 0;
}
return 1&&st.size()==n;
}
map<int,int>IMPORTANT;
set<int>alive;
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
int k=*max_element(gondolaSeq,gondolaSeq+n)-n;
int gondolaSeq2[250100],dn=0;
for(int i=0;i<n;i++){
if(gondolaSeq[i]<=n){
if(!dn){
dn=1;
int j=i,k=gondolaSeq[i];
do {
gondolaSeq2[j]=k;
j=(j+1)%n;
k=k%n+1;
}while(j-i);
}
} else {
IMPORTANT[gondolaSeq[i]]=i+1;
alive.insert(i);
}
}
if(!dn){
iota(gondolaSeq2,gondolaSeq2+n,1);
}
for(int i=n;i++<n+k;){
if(IMPORTANT[i]){
int k=IMPORTANT[i]-1;
replacementSeq[i-n-1]=gondolaSeq2[k];
gondolaSeq2[k]=i;
alive.erase(k);
} else {
IMPORTANT.erase(i);
replacementSeq[i-n-1]=gondolaSeq2[*alive.begin()];
gondolaSeq2[*alive.begin()]=i;
}
}
return k;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
Compilation message (stderr)
# | 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... |