# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
70091 | zubec | Gondola (IOI14_gondola) | C++14 | 29 ms | 2536 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;
const int N = 100100;
int a[N], b[N];
int valid(int n, int inputSeq[]){
map<int, int> mp1;
map<int, int> used, used2;
for (int i = 1; i <= n; i++){
a[i] = inputSeq[i-1];
if (a[i] > n){
if (++mp1[a[i]] > 1)
return 0;
}
}
a[n+1] = a[1];
int prev = 0;
for (int i = 1; i <= n; i++){
if (used.find(a[i+1]) != used.end())
a[i+1] = used[a[i+1]];
if (a[i] > n)
continue;
if (a[i+1] > n){
if (a[i] == n){
if (used2.find(1) != used2.end())
return 0;
used[a[i+1]] = 1;
used2[1] = a[i+1];
a[i+1] = 1;
} else {
if (used2.find(a[i]+1) != used2.end())
return 0;
used[a[i+1]] = a[i]+1;
used2[a[i]+1] = a[i+1];
a[i+1] = a[i]+1;
}
} else {
if (a[i] == n){
if (a[i+1] != 1)
return 0;
} else {
if (a[i+1] != a[i] + 1)
return 0;
}
}
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
vector <pair<int, int> > vec;
for (int i = 1; i <= n; i++){
a[i] = gondolaSeq[i-1];
if (a[i] > n){
vec.push_back({a[i], i});
}
}
a[n+1] = a[1];
for (int i = 1; i <= n; i++){
if (a[i] <= n){
if (a[i] == n)
a[i+1] = 1; else
a[i+1] = a[i] + 1;
}
}
for (int i = n+1; i > 1; i--){
if (a[i] <= n){
if (a[i] == 1)
a[i-1] = n; else
a[i-1] = a[i-1];
}
}
a[1] = min(a[1], a[n+1]);
int cnt = 0;
int curnumb = n+1;
sort(vec.begin(), vec.end());
for (int i = 0; i < vec.size(); i++){
int cur = a[vec[i].second];
while(cur != vec[i].first){
replacementSeq[cnt++] = cur;
cur = curnumb;
++curnumb;
}
}
return cnt;
}
//----------------------
int countReplacement(int n, int inputSeq[]){
return -3;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |