| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 58340 | E869120 | Sorting (IOI15_sorting) | C++14 | 313 ms | 536 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int N, S[200009], M, X[200009], Y[200009], A[200009];
vector<pair<int, int>> solve(int pos) {
// 74 点解法
vector<pair<int, int>>Z; int cx = 0;
for (int i = 0; i < N; i++) {
vector<int>B(N, 0), C(N, 0);
for (int j = 0; j < N; j++) { B[j] = S[j]; C[j] = j; }
for (int j = 0; j < cx; j++) {
swap(B[X[j]], B[Y[j]]);
swap(B[Z[j].first], B[Z[j].second]);
}
for (int j = pos - 1; j >= cx; j--) swap(C[X[j]], C[Y[j]]);
int s1 = 0, s2 = 0;
for (int j = 0; j < N; j++) {
if (B[j] == i) s1 = j; if (C[j] == i) s2 = j;
}
if (s1 == s2) continue;
Z.push_back(make_pair(s1, s2)); cx++;
}
for (int i = 0; i < N; i++) A[i] = S[i];
while (Z.size() < pos) Z.push_back(make_pair(0, 0));
for (int i = 0; i < pos; i++) {
swap(A[X[i]], A[Y[i]]);
swap(A[Z[i].first], A[Z[i].second]);
}
for (int i = 0; i < N; i++) {
if (A[i] != i) return vector<pair<int, int>>{make_pair(-1, -1)};
}
return Z;
}
int findSwapPairs(int NN, int SS[], int MM, int XX[], int YY[], int P[], int Q[]) {
N = NN; M = MM;
for (int i = 0; i < NN; i++) S[i] = SS[i];
for (int i = 0; i < MM; i++) { X[i] = XX[i]; Y[i] = YY[i]; }
int L = 0, R = N + 1, M_; vector<pair<int, int>>ret;
for (int i = 0; i < 20; i++) {
M_ = (L + R) / 2;
vector<pair<int, int>> z = solve(M_);
if (z == vector<pair<int, int>>{make_pair(-1, -1)}) L = M_;
else { R = M_; ret = z; }
}
for (int i = 0; i < ret.size(); i++) { P[i] = ret[i].first; Q[i] = ret[i].second; }
return ret.size();
}컴파일 시 표준 에러 (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... | ||||
