# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1004838 | u_suck_o | Gondola (IOI14_gondola) | C++17 | 6 ms | 1372 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"
#include "gondola.h"
using namespace std;
int valid(int n, int inputSeq[])
{
bool seen[250001];
memset(seen, 0, sizeof seen);
bool found = false;
int diff = -1;
for (int i = 0; i < n; i++) {
if (seen[inputSeq[i]]) return 0;
seen[inputSeq[i]] = true;
if (inputSeq[i] > n) continue;
if (!found) {
found = true;
diff = (inputSeq[i] - i + n) % n;
} else {
if ((inputSeq[i] - i + n) % n != diff)
return 0;
}
}
return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int diff = 0;
for (int i = 0; i < n; i++) {
if (gondolaSeq[i] <= n) {
diff = (gondolaSeq[i] - i + n) % n;
break;
}
}
vector<pair<int, int>> v;
for (int i = 0; i < n; i++) {
if (gondolaSeq[i] > n)
v.push_back({gondolaSeq[i], (i+diff) % n});
}
sort(v.begin(), v.end());
int last = n; //last assigned gondola #
vector<int> rep;
for (int i = 0; i < v.size(); i++) {
rep.push_back(v[i].second);
for (int j = last+1; j < v[i].first; j++)
rep.push_back(j);
last = v[i].first;
}
for (int i = 0; i < rep.size(); i++)
replacementSeq[i] = rep[i];
return rep.size();
}
//----------------------
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... |