Submission #681148

#TimeUsernameProblemLanguageResultExecution timeMemory
681148Ronin13Arranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include <iostream>
#include <unordered_map>
#include "shoes.h"

using namespace std;

long long count_swaps(vector <long long> shoes) {
  	long long n = shoes.size();
    unordered_map<long long, long long> size_count;
    for (long long i = 0; i < n; i++) {
        size_count[shoes[i]] = size_count[shoes[i]] + 1;
    }
    long long swaps = 0;
    for (long long i = 0; i < n; i++) {
        if (shoes[i] < 0) {
            continue;
        }
        long long matching_shoe = -shoes[i];
        if (size_count[matching_shoe] <= 0) {
            continue;
        }
        size_count[matching_shoe]--;
        long long 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/ccXqCcg0.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