Submission #1019468

#TimeUsernameProblemLanguageResultExecution timeMemory
1019468NicolaikrobArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <bits/extc++.h> using namespace std; using namespace __gnu_pbds; typedef long long ll; ll count_swaps(vector<int> S) { ll n = S.size(), ans = 0; tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> T; unordered_map<int, deque<int>> M; M.reserve(n); for(int i = 0; i < n; i++) M[S[i]].push_back(i); for(int i = 0; i < n; i++) T.insert({i,S[i]}); for(int i = 0; i < n/2; i++) { auto itr = T.find_by_order(0); int val = -(*itr).second; ans += (ll)T.order_of_key({M[val].front(), val}); if(val > 0) ans -= 1LL; T.erase(itr); T.erase(T.find({M[val].front(), val})); M[val].pop_front(); M[-val].pop_front(); } return ans; } int main() { int t; vector<int> Q; while(cin>>t) Q.push_back(t); cout << count_swaps(Q); }

Compilation message (stderr)

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