# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
532448 | antonioqbab | 정렬하기 (IOI15_sorting) | C++14 | 1 ms | 460 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#include <sorting.h>
using namespace std;
int findSwapPairs(int n, int s[], int m, int x[], int y[], int s1[], int s2[]) {
vector<int> p(n);
for (int i = 0; i < n; ++i)
p[i] = s[i];
int left = 0, right = n - 1;
auto ok = [&](int pos) {
auto p_ = p;
for (int i = 0; i <= pos; ++i)
swap(p_[x[i]], p_[y[i]]);
int ans = n;
vector<int> seen(n);
for (int i = 0; i < n; ++i)
if (!seen[i]) {
--ans;
seen[i] = 1;
for (int j = p_[i]; j != i; j = p_[j])
seen[j] = 1;
}
return ans <= pos + 1;
};
while (left < right) {
int m = (left + right) / 2;
if (ok(m))
right = m;
else
left = m + 1;
}
auto p_ = p;
for (int i = 0; i <= left; ++i)
swap(p_[x[i]], p_[y[i]]);
int cur = 0;
vector<int> seen(n);
for (int i = 0; i < n; ++i)
if (!seen[i] && p_[i] != i) {
vector<int> sol = {i};
for (int j = p_[i]; j != i; j = p_[j])
sol.emplace_back(j), seen[j] = 1;
for (int i = 0; i < (int)sol.size() - 1; ++i)
s1[cur] = sol[i], s2[cur++] = sol[i + 1];
}
// find real indices
return left;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |