이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second
using ii = pair<int, int>;
const int MAX = 250069;
int valid(int n, int inputSeq[])
{
bitset<MAX> vst;
for (int i = 0; i < n; ++i)
{
if (vst[i])
return 0;
vst[i] = true;
}
int pos = -1;
for (int i = 0; i < n; ++i) if (inputSeq[i] <= n)
{
int tmp = (inputSeq[i] - i + n) % n;
if (pos == -1) pos = tmp;
if (pos != tmp) return 0;
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int ar[MAX];
{
int pos = 0;
for (int i = 1; i < n; ++i)
if (gondolaSeq[i] < gondolaSeq[pos])
pos = i;
if (gondolaSeq[pos] <= n)
pos = (pos - gondolaSeq[pos] + 1 + n) % n;
else pos = 0;
iota(ar+pos, ar+n, 1);
iota(ar, ar+pos, n-pos+1);
}
vector<ii> v;
for (int i = 0; i < n; ++i)
v.pb({gondolaSeq[i], i});
sort(v.begin(), v.end());
int sz = 0, cur = n+1;
for (auto &[x, pos] : v)
{
while (ar[pos] != x)
{
replacementSeq[sz++] = ar[pos];
ar[pos] = cur++;
}
}
return sz;
}
//----------------------
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... |