Submission #681145

#TimeUsernameProblemLanguageResultExecution timeMemory
681145Ronin13Arranging Shoes (IOI19_shoes)C++14
Compilation error
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; }

Compilation message (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