#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 1;
const int MAX_N = 1e5;
int valid(int n, int inputSeq[]) {
int pos = 0, minn = INF + 1;
for (int i = 0; i < n; i++) {
if (inputSeq[i] < minn) {
minn = inputSeq[i];
pos = i;
}
}
int a = minn;
int i = pos;
do {
if (inputSeq[i] <= n) {
if (inputSeq[i] != a)
return false;
a++;
}
i = (i + 1) % n;
} while (i != pos);
return true;
}
//----------------------
int realVal[MAX_N];
int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
int pos = 0, minn = INF + 1;
for (int i = 0; i < n; i++) {
if (gondolaSeq[i] < minn) {
minn = gondolaSeq[i];
pos = i;
}
}
int a = minn;
int i = pos;
vector<pair<int, int>> v;
do {
realVal[i] = a;
if (gondolaSeq[i] <= n)
a = a % n + 1;
else
v.push_back({gondolaSeq[i], i});
i = (i + 1) % n;
} while (i != pos);
int rep = n + 1;
sort(v.begin(), v.end());
int l = 0;
for (auto p: v) {
replacementSeq[l++] = realVal[p.second];
while (rep < p.first) {
replacementSeq[l++] = rep;
rep++;
}
}
return l;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
# | 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... |