이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef vector<int> vi;
int valid(int n, int inputSeq[]){
vi a(inputSeq, inputSeq + n);
// handle whether all values are unique
vi b(a.begin(), a.end());
sort(ALL(b)); b.erase(unique(ALL(b)), b.end());
if (b.size() != a.size()) return 0;
// handle min element
vi::iterator mnit = min_element(a.begin(), a.end());
int mn = *mnit, pos = mnit - a.begin();
if (mn >= n) return 1;
// rotate elements so that min is at first position.
// now index i will be original position of (mn + i - 1)%n + 1;
rotate(a.begin(), a.begin() + pos, a.end());
// validity check
for (int i = 0; i < n; i++){
if (a[i] > n) continue;
if (a[i] != ((mn + i - 1) % n + 1)) return 0;
}
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... |