Submission #411800

#TimeUsernameProblemLanguageResultExecution timeMemory
411800timmyfengArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #include <bits/extc++.h> template <class T, class Comp = less<T>> using ordered_set = __gnu_pbds::tree< T, __gnu_pbds::null_type, Comp, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update >; long long count_swaps(vector<int> s) { int n = s.size() / 2; map<int, vector<int>> nxt; ordered_set<int> shoes; for (int i = 2 * n - 1; i >= 0; --i) { nxt[s[i]].push_back(i); shoes.insert(i); } long long ans = 0; while (!shoes.empty()) { auto i = *shoes.begin(); shoes.erase(shoes.begin()); int x = s[i]; nxt[x].pop_back(); int j = nxt[-x].back(); nxt[-x].pop_back(); ans += shoes.order_of_key(j) + (x > 0); shoes.erase(j); } return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> s(2 * n); for (int i = 0; i < 2 * n; ++i) { cin >> s[i]; } cout << count_swaps(s) << "\n"; }

Compilation message (stderr)

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