제출 #1364598

#제출 시각아이디문제언어결과실행 시간메모리
1364598takoshanavaArranging Shoes (IOI19_shoes)C++20
컴파일 에러
0 ms0 KiB
#include "shoes.h"
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fs first
#define sc second
using namespace std;

const int N = 1e5 + 5;
int n, bit[N];

void upd(int idx, int val){
    while(idx <= N){
        bit[idx] += val;
        idx += idx & -idx;
    }
}

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

int count_swaps(vector<int> s){
    n = s.size();
    map<int, deque<int>> lft, rgh;

    vector<int> tr(n);

    int id = 0;

    for(int i = 0; i < n; i++){
        int x = s[i];
        int sz = abs(x);
        if(x > 0){
            if(rgh[sz].empty()){
                int j = rgh[sz].front();
                rgh[sz].pop_front();
                id++;
                tr[j] = 2 * id, tr[i] = 2 * id - 1;
            }else{
                lft[sz].pb(i);
            }
        }else{
            if(lft[sz].empty()){
                int j = lft[sz].front();
                lft[sz].pop_front();
                id++;
                tr[j] = 2 * id - 1, tr[i] = 2 * id;
            }else{
                rgh[sz].pb(i);
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += i - get(tr[i]);
        upd(tr[i], 1);
    }
    return ans;
}

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

/usr/bin/ld: /tmp/ccfAK0oV.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