# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
896765 | 2024-01-02T05:46:49 Z | LCJLY | Gondola (IOI14_gondola) | C++14 | 0 ms | 0 KB |
#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; }