# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1042273 | dpsaveslives | 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>
using namespace std;
int valid(int n, int inputSeq[]){
int pos = -1; set<int> vals;
for(int i = 0;i<n;++i){
if(inputSeq[i] <= n && pos == -1){
pos = i;
}
vals.insert(inputSeq[i]);
}
if(vals.size() != n){
return 0;
}
if(pos == -1){
return 1;
}
int cur = inputSeq[pos];
for(int i = pos;i<n;++i){
if(inputSeq[i] <= n){
//cout << i << " " << cur << "\n";
if(inputSeq[i] != cur){
return 0;
}
}
if(cur == n){
cur = 0;
}
++cur;
}
for(int i = 0;i<=pos-1;++i){
if(inputSeq[i] <= n){
if(inputSeq[i] != cur){
return 0;
}
}
if(cur == n){
cur = 0;
}
++cur;
}
return 1;
}