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 <vector>
#include <algorithm>
#include <iostream>
#define int int64_t
using namespace std;
signed valid(signed n, signed inputSeq[])
{
for (int i = 0; i < n; i++) inputSeq[i]--;
int zval = 0;
for (int i = 0; i < n; i++)
{
if (inputSeq[i] < n)
{
zval = inputSeq[i] - i;
break;
}
}
for (int i = 0; i < n; i++)
{
if (inputSeq[i] < n)
{
if ((zval + i + n) % n != inputSeq[i]) return 0;
}
}
return 1;
}
//----------------------
signed replacement(signed n, signed gondolaSeq[], signed replacementSeq[])
{
vector<int> Seq;
for (int i = 0; i < n; i++) Seq.push_back(gondolaSeq[i] - 1);
int zval = 0;
for (int i = 0; i < n; i++)
{
if (Seq[i] < n)
{
zval = Seq[i] - i;
break;
}
}
rotate(Seq.rbegin(), Seq.rbegin() + ((zval + n) % n), Seq.rend());
int mmax = *max_element(Seq.begin(), Seq.end());
int mind = -1;
for (int i = 0; i <= mmax - n; i++) replacementSeq[i] = -1;
for (int i = 0; i < n; i++)
{
if (Seq[i] == mmax) mind = i;
if (Seq[i] >= n) replacementSeq[Seq[i] - n] = i + 1;
}
mind++;
for (int i = 0; i <= mmax - n; i++)
{
if (replacementSeq[i] == -1)
{
replacementSeq[i] = mind;
mind = n + i + 1;
}
}
replacementSeq[mmax - n] = mind;
return mmax - n + 1;
}
//----------------------
signed countReplacement(signed n, signed inputSeq[])
{
for (int i = 0; i < n; i++) inputSeq[i]--;
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... |