# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
702144 | mychecksedad | Gondola (IOI14_gondola) | C++17 | 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>
#include <gondola.h>
using namespace std;
int valid(int n, int a[]){
map<int, bool> m;
for(int i = 0; i < n; ++i){
if(m[a[i]]){
return 0;
}
m[a[i]] = 1;
}
int mn = -1;
for(int i = 0; i < n; ++i){
if(a[i] <= n){
mn = mn == -1 ? i : (a[mn] < a[i] ? mn : i);
}
}
int s = a[mn];
for(int i = mn; i != mn; (i += 1) %= n, s++){
if(s == n + 1) s = 1;
if(a[i] <= n && a[i] != s){
return 0;
}
}
return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[]);
int countReplacement(int n, int inputSeq[]);