Submission #1144673

#TimeUsernameProblemLanguageResultExecution timeMemory
1144673crispxxArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "shoes.h" #include "grader.cpp" using namespace std; #define all(x) x.begin(), x.end() #define pb push_back #define nl '\n' struct Fenw { int n; vector<int> t; Fenw(int n) : n(n), t(n + 1) {} void update(int i, int x) { i++; for(; i <= n; i += i & -i) t[i] += x; } int get(int i) { int res = 0; for(; i >= 1; i -= i & -i) res += t[i]; return res; } int get(int l, int r) { return get(r + 1) - get(l); } }; long long count_swaps(vector<int> s) { int n = s.size(); long long ans = 0; Fenw fn(n); bool flag = 0; map<int, set<int>> st; for(int i = 0; i < n; i++) { st[s[i]].emplace(i); } for(int i = 0; i < n; i++) { if(fn.get(i, i)) continue; int x = s[i]; if(flag != (x > 0)) { int y = -x; assert(!st[y].empty()); int j = *st[y].begin(); st[y].erase(st[y].begin()); ans += j - i - fn.get(i, j); fn.update(j, 1); } else flag = !flag; st[x].erase(i); } return ans; } /** 4 2 -2 2 2 -2 -2 -2 2 4 2 -2 2 -2 2 -2 2 -2 **/

Compilation message (stderr)

/usr/bin/ld: /tmp/ccLCJ4Lt.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccoN6eZR.o:shoes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status