이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include<bits/stdc++.h>
using namespace std;
/*
* If there is a duplicate, return 0.
* If all numbers are > n, return 1.
* idxMini -> index of minimum number. If I go around (n - 1) steps starting from idxMini, the numbers which is <= n
should appear in increasing order.
*/
int valid(int n, int inputSeq[]) {
set<int> uniqNumbers;
int idxMini = -1;
for (int i = 0; i < n; i++) {
// There is a duplicate
if (uniqNumbers.find(inputSeq[i]) != uniqNumbers.end()) {
return 0;
}
uniqNumbers.insert(inputSeq[i]);
if (inputSeq[i] <= n) {
if (idxMini == -1 || inputSeq[i] < inputSeq[idxMini]) {
idxMini = i;
}
}
}
// All numbers are > n.
if (idxMini == -1) {
return 1;
}
int lastNumber = inputSeq[idxMini];
for (int i = (idxMini + 1)%n, step = 1; step <= n - 1; i = (i + 1)%n, step++) {
if (inputSeq[i] <= n) {
if (inputSeq[i] < lastNumber) {
return 0;
}
lastNumber = inputSeq[i];
}
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
return -2;
}
//----------------------
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... |