# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
788795 | acatmeowmeow | Gondola (IOI14_gondola) | C++11 | 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;
#define int long long
int valid(int n, int inputSeq[]) {
ios::sync_with_stdio(false);
cin.tie(nullptr);
set<int> st;
for (int i = 0; i < n; i++) {
if (st.count(inputSeq[i])) return 0;
st.insert(inputSeq[i]);
}
int lowest = 1e18, pos = 1e18;
for (int i = 0; i < n; i++) {
if (lowest > inputSeq[i]) {
lowest = inputSeq[i], pos = i;
}
}
if (lowest > n) return 1;
for (int i = pos, cnt = lowest, len = 1; len <= n; i = (i + 1) % n, len++, cnt = cnt % n + 1) {
if (inputSeq[i] > n) continue;
if (cnt != inputSeq[i]) return 0;
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
return -2;
}
//----------------------
int countReplacement(int n, int inputSeq[]) {
return -3;
}
/*int gondolaSequence[100001];
int replacementSequence[250001];
signed main()
{
int i, n, tag;
int nr;
//assert(scanf("%d", &tag)==1);
//assert(scanf("%d", &n)==1);
cin >> tag >> n;
for(i=0;i< n;i++) cin >> gondolaSequence[i];
//assert( scanf("%d", &gondolaSequence[i]) ==1);
switch (tag){
case 1: case 2: case 3:
printf("%d\n", valid(n, gondolaSequence));
break;
case 4: case 5: case 6:
nr = replacement(n, gondolaSequence, replacementSequence);
printf("%d ", nr);
if (nr > 0)
{
for (i=0; i<nr-1; i++)
printf("%d ", replacementSequence[i]);
printf("%d\n", replacementSequence[nr-1]);
}
else printf("\n");
break;
case 7: case 8: case 9: case 10:
printf("%d\n", countReplacement(n, gondolaSequence));
break;
}
return 0;
}*/