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;
// trans rights
#define ll long long
#define f first
#define s second
#define endl '\n'
#define all(x) begin(x), end(x)
int valid(int n, int inputSeq[])
{
int tmp = -1;
for (int i = 0; i < n; i++) {
if (inputSeq[i] <= n) {
int cur = (inputSeq[i] - i + n) % n;
if (tmp == -1) tmp = cur;
if (tmp != cur) return 0;
}
}
return 1;
}
//----------------------
int ori[100069];
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int offst = 1;
pair<int,int> maxi = {0, -1};
for (int i = 0; i < n; i++) {
if (gondolaSeq[i] <= n) {
offst = gondolaSeq[i] - i;
}
maxi = max(maxi, {gondolaSeq[i], i});
}
for (int i = 0; i < n; i++) {
ori[i] = (i + offst + n) % n;
if (ori[i] == 0) ori[i] = n;
}
int l = maxi.f - n;
for (int i = 0; i < l; i++) {
replacementSeq[i] = -1;
}
for (int i = 0; i < n; i++) {
if (gondolaSeq[i] > n && gondolaSeq[i] != maxi.f) {
replacementSeq[gondolaSeq[i] - n - 1] = ori[i];
}
}
int cur = ori[maxi.s];
for (int i = 0; i < l; i++) {
if (!replacementSeq[i]) continue;
replacementSeq[i] = cur;
cur = i + n + 1;
}
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... |