이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<int> vi;
int valid(int n, int inputSeq[])
{
FOR(i, 0, n-1) inputSeq[i]--;
unordered_set<int> cont;
FOR(i, 0, n-1) cont.insert(inputSeq[i]);
if ((int)cont.size() < n) return false;
int ch = -1;
FOR(i, 0, n-1) {
if (inputSeq[i] >= n) continue;
ch = i;
break;
}
if (ch == -1) return true;
FOR(i, 0, n-1) {
int id = (ch+i)%n;
if (inputSeq[id] >= n) continue;
int shouldBe = (inputSeq[ch]+i)%n;
if (inputSeq[id] != shouldBe) return false;
}
return true;
}
//----------------------
int replacement(int n, int inputSeq[], int replacementSeq[])
{
FOR(i, 0, n-1) inputSeq[i]--;
int l = 0;
int ch = 0;
FOR(i, 0, n-1) {
if (inputSeq[i] >= n) continue;
ch = i;
break;
}
int cur[n];
cur[ch] = (inputSeq[ch] < n ? inputSeq[ch] : 0);
FOR(i, 0, n-1) {
int id = (ch+i)%n;
int shouldBe = (cur[ch]+i)%n;
cur[id] = shouldBe;
}
vii seq;
FOR(i, 0, n-1) {
seq.pb({inputSeq[i], i});
}
sort(seq.begin(), seq.end());
int crAdd = n;
for (auto p : seq) {
int id = p.s;
while (cur[id] < inputSeq[id]) {
replacementSeq[l] = cur[id]+1;
cur[id] = crAdd;
crAdd++;
l++;
}
}
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... |