# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
896765 | LCJLY | Gondola (IOI14_gondola) | C++14 | 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 <bits/stdc++.h>
using namespace std;
int valid(int n, int arr[]){
unordered_set<int>se;
bool amos=true;
deque<int>d;
int mini=INT_MAX;
for(int x=0;x<n;x++){
if(se.find(arr[x])!=se.end()) amos=false;
se.insert(arr[x]);
if(arr[x]<=n){
d.push_back(arr[x]);
mini=min(mini,arr[x]);
}
}
int ptr=1;
for(int x=1;x<=n;x++){
if(se.find(x)==se.end()){
if(se.find(ptr+n)==se.end()) amos=false;
ptr++;
}
}
if(!d.empty()){
while(d.front()!=mini){
d.push_front(d.back());
d.pop_back();
}
for(int x=1;x<(int)d.size();x++){
if(d[x]<d[x-1]) amos=false;
}
}
return amos;
}