제출 #1276081

#제출 시각아이디문제언어결과실행 시간메모리
1276081nanaseyuzukiArranging Shoes (IOI19_shoes)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
// Author: Kazuki_Will_Win_VOI_8703
#define fi first
#define se second
#define pii pair<int, int>
#define ll long long
#define all(a) a.begin(), a.end()
using namespace std;

const int mn = 1e6 + 5, bm = (1 << 20) + 1;
const int inf = 1e9;

int n, a[mn];
map <int, queue<int>> mp;

int bit[mn];

void add(int u, int val){
    while(u <= n){
        bit[u] += val;
        u += (u & -u);
    }
}

int get(int u){
    int res = 0;
    while(u){
        res += bit[u];
        u -= (u & -u);
    }
    return res;
}

ll count(vector <int> s){
    n = s.size();
    for(int i = 0; i < n; i++){
        a[i + 1] = s[i];
    }
    ll res = 0;
    for(int i = 1; i <= n; i++){
        if(mp.count(- a[i]) && mp[- a[i]].size()){
            int j = mp[- a[i]].front(); mp[- a[i]].pop();
            if(a[i] < 0){
                add(i, 1);
                res += 1ll * (i - get(i));
                add(j, 1);
                res += 1ll * (j - get(j));
            }
            else{
                add(j, 1);
                res += 1ll * (j - get(j));
                add(i, 1);
                res += 1ll * (i - get(i));
            }
        }
        else{
            mp[a[i]].push(i);
        }
    }
    return res;
}

// signed main(){
//     ios_base::sync_with_stdio(false);
//     cin.tie(NULL);
//     cout.tie(NULL);
//     cout << count({2, 1, -1, -2}) << '\n';
// }

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/cc7qydYT.o: in function `main':
grader.cpp:(.text.startup+0x26b): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status