이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Ignut
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll count_swaps(vector<int> S) {
    ll res = 0;
    int n = S.size();
    for (int i = 1; i < n; i += 2) {
        int target = -S[i - 1];
        int j;
        for (j = i; j < n; j ++)
            if (S[j] == target)
                break;
        while (j > i) {
            swap(S[j - 1], S[j]);
            j --;
            res ++;
        }
        if (S[i - 1] > 0) {
            swap(S[i - 1], S[i]);
            res ++;
        }
        // if (i % 2 == 0) {
        //     int j;
        //     for (j = i; j < n; j ++)
        //         if (S[j] < 0) 
        //             break;
        //     while (j > i) {
        //         swap(S[j - 1], S[j]);
        //         j --;
        //         res ++;
        //     }
        // }
        // else {
        //     int j;
        //     for (j = i; j < n; j ++)
        //         if (S[j] == -S[i - 1])
        //             break;
        //     while (j > i) {
        //         swap(S[j - 1], S[j]);
        //         j --;
        //         res ++;
        //     }
        // }
    }
    
    // for (int sz = 1; sz <= n / 2; sz ++) {
    //     res += sz - 1;
    // }
    /*int pos = 0;
    for (int i = 0; i < n; i ++) {
        if (S[i] > 0) continue;
        res += abs(i - pos);
        pos += 2;
    }*/
    return res;
}
| # | 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... |