Submission #222882

#TimeUsernameProblemLanguageResultExecution timeMemory
222882MrDominoArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> ///#include "shoes.h" using namespace std; typedef long long ll; ll get_dist(vector<int> ord) { int n = (int) ord.size(); vector<int> aib(n + 1); ll sol = 0; for (int i = 0; i < n; i++) { sol += i; int x = ord[i] + 1, y = x; while (x) { sol -= aib[x]; x -= x & (-x); } x = y; while (x <= n) { aib[x]++; x += x & (-x); } } return sol; } const int N = (int) 1e5 + 7; vector<int> pl[N]; vector<int> mn[N]; struct T { int l; int r; }; bool operator < (T a, T b) { return a.l + a.r < b.l + b.r; } long long count_swaps(vector<int> a) { int n = (int) a.size() / 2; for (int i = 0; i < 2 * n; i++) { pl[a[i]].push_back(i); mn[-a[i]].push_back(i); } vector<T> p; for (int i = 1; i <= n; i++) { for (int j = 0; j < (int) pl[i].size(); j++) { p.push_back({mn[i][j], pl[i][j]}); } } sort(p.begin(), p.end()); vector<int> ord; for (auto &it : p) { ord.push_back(it.l); ord.push_back(it.r); } return get_dist(ord); } int main() { cout << count_swaps({2, 1, -1, -2}); }

Compilation message (stderr)

/tmp/ccVmeVxX.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccGgONgp.o:shoes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status