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;
const int M = 250005;
int valid(int n, int seq[])
{
vector<int> vis(M);
for (int i = 0; i < n; i++) vis[seq[i]] = true;
bool imp = false;
for (int i = n; i < M; i++)
{
if (!vis[i])
{
imp = 1;
} else
{
if (imp) return 0;
}
}
int cur = -1;
for (int i = 0; i < n; i++) seq[i]--;
for (int i = 0; i < n; i++)
{
if (seq[i] < n)
{
cur = i;
break;
}
}
if (cur == -1) return 1;
int val = seq[cur];
for (int i = cur + 1; i < n; i++)
{
val++;
val %= n;
if (seq[i] < n && seq[i] != val) return 0;
}
return 1;
}
//----------------------
int replacement(int n, int seq[], int seq2[])
{
vector<int> to(M, -1);
int biggest = -1;
int cbig = -1;
for (int i = 0; i < n; i++)
{
seq[i]--;
to[seq[i]] = i;
if (seq[i] > cbig)
{
cbig = seq[i];
biggest = i;
}
}
if (cbig == n - 1) return 0;
int org[M];
for (int i = 0; i < n; i++) org[i] = -1;
for (int i = 0; i < n; i++)
{
if (seq[i] < n)
{
for (int j = 0; j < n; j++)
{
org[j] = ((seq[i] - (i - j)) % n + n) % n;
}
break;
}
}
if (org[0] == -1)
{
for (int i = 0; i < n; i++) org[i] = i;
}
int cur = 0;
for (int cnum = n; cnum <= cbig; cnum++)
{
if (to[cnum] == -1)
{
seq2[cur] = org[biggest] + 1;
org[biggest] = cnum;
} else
{
seq2[cur] = org[to[cnum]] + 1;
org[to[cnum]] = cnum;
}
cur++;
}
return cur++;
}
/*
4
2
10 11
*/
//----------------------
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... |