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;
int valid(int n, int inputSeq[]) {
int minx = (1 << 30), minid = -1; map<int, int>Map;
for (int i = 0; i < n; i++) { if (minx > inputSeq[i]) { minx = inputSeq[i]; minid = i; } if (Map[inputSeq[i]] == 1) return 0; Map[inputSeq[i]] = 1;}
for (int i = 0; i < n; i++) {
int s = (i + minid) % n;
if (inputSeq[s] <= n && inputSeq[s] != i + 1) return 0;
}
return 1;
}
//----------------------
int id[250009];
int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
int G = 0; for (int i = 0; i < n; i++) { if (gondolaSeq[i] == 1) G = i; }
int maxn = 0;
for (int i = 0; i <= 250000; i++) id[i] = -1;
for (int i = 0; i < n; i++) { id[gondolaSeq[i]] = (i - G + n) % n; maxn = max(maxn, gondolaSeq[i]); }
for (int i = 0; i < n; i++) gondolaSeq[i] = i + 1;
for (int i = n + 1; i <= maxn; i++) {
if (id[i] >= 0) {
replacementSeq[i - (n + 1)] = gondolaSeq[id[i]];
gondolaSeq[id[i]] = i;
}
else {
replacementSeq[i - (n + 1)] = gondolaSeq[id[maxn]];
gondolaSeq[id[maxn]] = i;
}
}
return maxn - n;
}
//----------------------
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... |