| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 636447 | borisAngelov | Arranging Shoes (IOI19_shoes) | C++14 | 69 ms | 12712 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "shoes.h"
using namespace std;
const int MAXN = 200005;
int n;
vector<pair<int, int>> same_size[MAXN];
vector<pair<int, int>> matchings;
struct FenwickTree {
    int fenwick[MAXN];
    void update(int pos, int val) {
        while (pos < 2 * n) {
            fenwick[pos] += val;
            pos += (pos & (-pos));
        }
    }
    int query(int pos) {
        int result = 0;
        while (pos > 0) {
            result += fenwick[pos];
            pos -= (pos & (-pos));
        }
        return result;
    }
};
FenwickTree Fenwick;
long long count_swaps(std::vector<int> shoes) {
    n = int(shoes.size()) / 2;
    for (int i = 0; i < 2 * n; i++) {
        same_size[abs(shoes[i])].push_back({shoes[i], i});
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        sort(same_size[i].begin(), same_size[i].end());
        for (int j = 0; j < int(same_size[i].size()) / 2; j++) {
            int l = same_size[i][j].second;
            int r = same_size[i][j + int(same_size[i].size()) / 2].second;
            if (l > r) {
                swap(l, r);
                ans++;
            }
            matchings.push_back({l + 1, r + 1});
        }
    }
    sort(matchings.begin(), matchings.end());
    for (int i = 1; i <= 2 * n; i++) Fenwick.update(i, 1);
    for (int i = 0; i < matchings.size(); i++) {
        int l = matchings[i].first;
        int r = matchings[i].second;
        if (r - l > 1) ans += Fenwick.query(r - 1) - Fenwick.query(l);
        Fenwick.update(l, -1);
        Fenwick.update(r, -1);
    }
    return ans;
}
컴파일 시 표준 에러 (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... | ||||
