Submission #235651

#TimeUsernameProblemLanguageResultExecution timeMemory
235651triple_faultArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h" #include <set> #define ll long long #define mid ((tl + tr) / 2) using namespace std; ll n; vector<ll> shoes(200000); struct segtree { segtree* left = NULL; segtree* right = NULL; multiset<ll> here; ll m_tl, m_tr; void build(ll tl, ll tr) { m_tl = tl, m_tr = tr; if (tl == tr) { here.insert(shoes[tl]); return; } left = new segtree(); right = new segtree(); left->build(tl, mid); right->build(mid + 1, tr); merge(left->here.begin(), left->here.end(), right->here.begin(), right->here.end(), inserter(here, here.begin())); } ll query(ll needle) { here.erase(here.find(needle)); if (m_tl == m_tr) return m_tl; if (left->here.find(needle) != left->here.end()) return left->query(needle); else if (right->here.find(needle) != right->here.end()) return right->query(needle); else puts("fuck this"); return 696969696969696969; } } segtree; long long count_swaps(std::vector<int> s) { ll n = s.size(); for (ll i = 0; i < n; ++i) shoes[i] = (ll)s[i]; segtree.build(0, n - 1); ll active[n]; for (ll i = 0; i < n; ++i) active[i] = 1; ll ans = 0; for (ll i = 0; i < n; ++i) { if (!active[i]) continue; active[i] = 0; segtree.query(shoes[i]); ll nxt = -shoes[i]; ll q = segtree.query(nxt); active[q] = 0; ans += (q - i - 1); if (nxt < 0) ++ans; } return ans; }

Compilation message (stderr)

shoes.cpp: In member function 'void segtree::build(long long int, long long int)':
shoes.cpp:30:9: error: 'merge' was not declared in this scope
         merge(left->here.begin(), left->here.end(), right->here.begin(), right->here.end(),
         ^~~~~
shoes.cpp:30:9: note: suggested alternative: 'here'
         merge(left->here.begin(), left->here.end(), right->here.begin(), right->here.end(),
         ^~~~~
         here
shoes.cpp: In member function 'long long int segtree::query(long long int)':
shoes.cpp:42:14: error: 'puts' was not declared in this scope
         else puts("fuck this");
              ^~~~
shoes.cpp:42:14: note: suggested alternative: 'auto'
         else puts("fuck this");
              ^~~~
              auto