# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
403902 | Iwanttobreakfree | Gondola (IOI14_gondola) | C++98 | 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 "gondola.h"
#include <vector>
using namespace std;
int valid(int n, int inputSeq[]){
int mini=1e9,pos,cont=0;
for(int i=0;i<n;i++){
if(inputSeq[i]<mini){
mini=inputSeq[i];
pos=i;
}
}
vector<bool> visto(n,false);
vector<int>v(n);
for(int i=pos;i<n;i++){
v[cont]=inputSeq[i];
cont++;
}
for(int i=0;i<pos;i++){
v[cont]=inputSeq[i];
cont++;
}
for(int i=0;i<n;i++){
if(v[i]>n){
if(!visto[v[i]])visto[v[i]]=true;
else return 0;
}
if(v[i]-mini!=i)return 0;
}
return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
int maxi=0;
for(int i=0;i<n;i++){
if(inputSeq[i]>maxi){
maxi=inputSeq;
}
}
set<int> s;
for(int i=1;i<=maxi;i++){
s.insert(i);
}
for(int i=0;i<n;i++){
s.erase(inputSeq[i]);
}
int cont=0;
for(int x:s){
replacementSeq[cont]=x;
cont++;
}
return cont;
}
int countReplacement(int n, int inputSeq[]){
return -3;
}