| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 58352 | E869120 | 정렬하기 (IOI15_sorting) | C++14 | 58 ms | 512 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 点解法
for (int i = 0; i < N; i++) A[i] = S[i];
for (int i = 0; i < pos; i++) swap(A[X[i]], A[Y[i]]);
vector<pair<int, int>>Z;
for (int i = 0; i < N; i++) {
int s1 = 0;
for (int j = 0; j < N; j++) { if (A[j] == i) s1 = j; }
swap(A[i], A[s1]); Z.push_back(make_pair(i, s1));
}
if (Z.size() <= pos) return Z;
return vector<pair<int, int>>{make_pair(-1, -1)};
}
bool check(vector<pair<int, int>>res) {
for (int i = 0; i < N; i++) A[i] = S[i];
for (int i = 0; i < res.size(); i++) {
swap(A[X[i]], A[Y[i]]);
swap(A[res[i].first], A[res[i].second]);
}
for (int i = 0; i < N; i++) { if (A[i] != i) return false; }
return true;
}
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 = M + 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; }
//if (check(ret) == false) return -1;
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... | ||||
