# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
922834 | allin27x | 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 S[]){
vector<int> ns;
set<int> s; for(int i=0; i<n; i++) s.insert(S[i]); if (s.size()<n) return 0;
int ind = -1;
for (int i=0; i<n; i++) if (S[i] <= n) {ind = i; break;}
if (ind == -1) return 1;
int t = S[ind];
for (int i=ind+1; i!=ind; i++, i%=n){
t++; if (t==n+1) t = 1;
if (S[i] <= n && S[i] != t) return 0;
}
return 1;
}
// int main(){
// int S[] ={1, 5, 3, 4, 2, 7, 6};
// cout<<valid(7,S);
// }
int replacement(int n, int gondolaSeq[], int replacementSeq[]);
int countReplacement(int n, int inputSeq[]);