이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
const int base = 2<<17;
int tree[base*2+7];
void edit(int n){
    n+=base;
    while (n>0){
        tree[n] += 1;
        n/=2;
    }
}
int query(int a,int b){
    a+=base-1;
    b+=base+1;
    int wynik=0;
    while (a/2 != b/2){
        if (a%2==0) wynik += tree[a+1];
        if (b%2==1) wynik += tree[b-1];
        a/=2;
        b/=2;
    }
    return wynik;
}
long long count_swaps(vector<int>S){
    long long wynik = 0,idx_2,val,idx_3,size_,i;
    pair< vector<int>,int> idx[100007];
    priority_queue<pair<int,int>> kolejka;
    //pos, item
    for (int i; i<S.size(); ++i){
    
        if (S[i]>0) idx[S[i]].first.push_back(i);
        else kolejka.push({-i,S[i]});
    }
    size_ = S.size();
    while (!kolejka.empty()){
        idx_2 = -kolejka.top().first;
        val = kolejka.top().second;
        kolejka.pop();
        //cout << idx_2 << " " << val << endl;
        
        wynik += idx_2-i+query(idx_2+1,size_);
        edit(idx_2);
        //cout << wynik << endl;
        
        
        idx_3 = idx[-val].first[idx[-val].second];
        wynik += idx_3-(i+1)+query(idx_3+1,size_);
        edit(idx_3);
        //cout << wynik << endl << endl;
        idx[-val].second += 1;
        //cout<<"JAA";
        //idx[-val].second += 1;
        i+=2;
    }
    return wynik;
}
컴파일 시 표준 에러 (stderr) 메시지
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:36:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (int i; i<S.size(); ++i){
      |                 ~^~~~~~~~~
shoes.cpp:36:17: warning: 'i' is used uninitialized in this function [-Wuninitialized]
   36 |     for (int i; i<S.size(); ++i){
      |                 ^| # | 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... |