이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#include "gondola.h"
int countReplacement(int n, int a[]) {return 0;}
int valid(int n, int arr[]) {
map<int, bool> mp;
vector<int> v(arr, arr+n);
auto it = min_element(v.begin(), v.end());
rotate(v.begin(), it, v.end());
for (int i = 0; i < n; ++i) {
if (mp[v[i]]) return 0;
mp[v[i]] = true;
if (v[i] <= n and i != v[i] - v[0]) return 0;
}
return 1;
}
int replacement(int n, int a[], int b[]) {
vector<int> v(a, a+n);
auto it = min_element(v.begin(), v.end());
int mn = *it, pos = it - v.begin(), mx = *max_element(v.begin(), v.end());
rotate(v.begin(), v.begin() + (pos - mn%n + 1 + n) % n, v.end());
map<int, int> mp;
for (int i = 0; i < n; ++i) {
mp[v[i]] = i+1;
}
for (int i = n+1; i <= mx; ++i) {
if (mp.count(i)) b[i-n-1] = mp[i];
else {
b[i-n-1] = mp[mx];
mp[mx] = i;
}
}
return mx - n;
}
# | 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... |