제출 #574348

#제출 시각아이디문제언어결과실행 시간메모리
574348Trisanu_DasArranging Shoes (IOI19_shoes)C++17
컴파일 에러
0 ms0 KiB
#include "shoes.h"
#include<bits/stdc++.h>
using namespace std;
#define int long long int
 
const int N = 2e5+10;
 
int n, fenwick[N];
queue<int> shoes_l[N], shoes_r[N];
 
void upd(int pos, int val) {
    for(int i = pos; i <= n; i+= i&-i) {
        fenwick[i]+= val;
    }
}
 
int get(int pos) {
    int val = 0;
    for(int i = pos; i > 0; i-= i&-i) {
        val+= fenwick[i];
    }
    return val;
}
 
int count_swaps(vector<int> s) {
    n = s.size();
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        int temp = s[i-1];
 
        if(temp < 0) {
            temp *= -1;
            if(shoes_r[temp].size()){
                int pos = shoes_r[temp].front(); shoes_r[temp].pop();ans+= get(i) - get(pos-1);upd(pos,1);
            }
            else {
                shoes_l[temp].push(i); upd(i,1);
            }
        }
        else {
            if(shoes_l[temp].size()){
                int pos = shoes_l[temp].front(); shoes_l[temp].pop();ans+= get(i)-get(pos);upd(pos,1);
            }
            else {
                shoes_r[temp].push(i); upd(i,1);
            }
        }
    }
    return ans;
}

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

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