# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
955085 | 2024-03-29T10:58:43 Z | 4QT0R | Gondola (IOI14_gondola) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; #define pii pair<int,int> int valid(int n, int inputSeq[]){ set<int> s(inputSeq,inputSeq+n); if ((int)s.size()<n)return 0; pii mn={n+1,-1}; for (int i = 0; i<n; i++){ if (inputSeq[i]<mn.first)mn={inputSeq[i],i}; } int cur=mn.first; for (int i = mn.second+1; i<n; i++){ if (inputSeq[i]<=n && inputSeq[i]!=++cur)return 0; } for (int i = 0; ++cur<=n; i++){ if (inputSeq[i]<=n && inputSeq[i]!=cur)return 0; } return 1; }