# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
232097 | spdskatr | Gondola (IOI14_gondola) | C++14 | 31 ms | 2548 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 <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <utility>
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
int valid(int n, int inputSeq[]) {
int offset = -1;
for (int i = 0; i < n; i++) {
if (inputSeq[i] <= n) {
offset = (i - inputSeq[i] + 1 + n) % n;
break;
}
}
if (offset == -1) return 1;
else {
for (int i = 0; i < n; i++) {
int ind = (offset+i) % n;
if (inputSeq[ind] < n && inputSeq[ind] != i+1) return 0;
}
}
return 1;
}
//----------------------
namespace T2 {
int original[100005], cnt;
vector<pii> elems;
int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
int offset = -1;
for (int i = 0; i < n; i++) {
if (gondolaSeq[i] <= n) {
offset = (i - gondolaSeq[i] + 1 + n) % n;
break;
}
}
if (offset == -1) {
for (int i = 0; i < n; i++) original[i] = i+1;
} else {
for (int i = 0; i < n; i++) {
original[(offset+i)%n] = i+1;
}
}
for (int i = 0; i < n; i++) {
if (gondolaSeq[i] > n) {
elems.push_back({ gondolaSeq[i], i });
}
}
sort(elems.begin(), elems.end());
int cur = n+1;
for (int i = 0; i < elems.size(); i++) {
while (elems[i].fi >= cur) {
replacementSeq[cnt++] = original[elems[i].se];
original[elems[i].se] = cur++;
}
}
return cnt;
}
}
int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
return T2::replacement(n, gondolaSeq, replacementSeq);
}
//----------------------
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... |