제출 #681145

#제출 시각아이디문제언어결과실행 시간메모리
681145Ronin13Arranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include <iostream>
#include <unordered_map>
#include "shoes.h"
#define int long long 
using namespace std;

int count_swaps(vector <int> shoes) {
  	int n = shoes.size();
    unordered_map<int, int> size_count;
    for (int i = 0; i < n; i++) {
        size_count[shoes[i]] = size_count[shoes[i]] + 1;
    }
    int swaps = 0;
    for (int i = 0; i < n; i++) {
        if (shoes[i] < 0) {
            continue;
        }
        int matching_shoe = -shoes[i];
        if (size_count[matching_shoe] <= 0) {
            continue;
        }
        size_count[matching_shoe]--;
        int j = i + 1;
        while (shoes[j] != matching_shoe) {
            j++;
        }
        swap(shoes[i], shoes[j]);
        swaps += j - i;
    }
    return swaps;
}

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

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