| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1075257 | ArthuroWich | 정렬하기 (IOI15_sorting) | C++17 | 162 ms | 32224 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "sorting.h"
#include<bits/stdc++.h>
using namespace std;
vector<pair<int, int>> ans, xy, swaps;
bool check(vector<int> p, int m, int n) {
    int s = 0;
    vector<int> e = p;
    vector<int> co(n, 0);
    for (int i = 0; i < n; i++) {
        co[p[i]] = i;
    }
    for (int i = 0; i < m; i++) {
        swap(p[xy[i].first], p[xy[i].second]);
    }
    for (int i = 0; i < n; i++) {
        if (p[i] == i) {
            continue;
        }
        while(p[i] != i) {
            int j = p[i];
            swaps.push_back({p[i], p[j]});
            swap(p[i], p[j]);
            s++;
        }
    }
    if (swaps.size() > m) {
        return 0;
    }
    while(swaps.size() < m) {
        swaps.push_back({0, 0});
    }
    for (int i = 0; i < m; i++) {
        swap(co[e[xy[i].first]], co[e[xy[i].second]]);
        swap(e[xy[i].first], e[xy[i].second]);
        auto [x, y] = swaps[i];
        swaps[i] = {co[x], co[y]};
        swap(e[co[x]], e[co[y]]);
        swap(co[x], co[y]);
    }
    return s <= m;
}
int findSwapPairs(int n, int A[], int M, int X[], int Y[], int P[], int Q[]) {
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        p[i] = A[i];
    }
    for (int i = 0; i < M; i++) {
        xy.push_back({X[i], Y[i]});
    }
    int l = 0, r = M;
    while(l < r) {
        int m = (l+r)/2;
        swaps.clear();
        if (check(p, m, n)) {
            r = m;
            ans = swaps;
        } else {
            l = m+1;
        }
    }
    for (int i = 0; i < ans.size(); i++) {
        P[i] = ans[i].first;
        Q[i] = ans[i].second;
    }
    return ans.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... | ||||
