Submission #1216932

#TimeUsernameProblemLanguageResultExecution timeMemory
1216932pensiveArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define REP(a,i,n) for (ll i=a;i<n;i++) map<ll, queue<ll> > saan; struct SegTree { ll l, r, val; SegTree* lt, * rt; void combine() { val = lt->val + rt->val; } SegTree(ll left, ll right, vector<ll>& a) { l = left; r = right; lt = rt = nullptr; if (left==right) { val = a[left]; return; } ll mid = (l+r)>>1; lt = new SegTree(l, mid, a); rt = new SegTree(mid+1, r, a); combine(); } void update(ll i){ if(l <= i && i <= r){ if (lt) { lt->update(i); rt->update(i); combine(); } else { val++; } } } ll query(ll ql, ll qr) { if (qr < l || r < ql) { // completely out return 0; } if ( ql <= l && r <= qr) { //completely in return val; } return lt->query(ql, qr) + rt->query(ql, qr); } }; ll count_swaps(vector<ll> S) { vector<ll> arr; ll N=S.size(), ind=0, count=0; for (ll shoe : S) { if (saan[shoe].empty()) { saan[-shoe].push(ind + (shoe < 0)); //push the opposite arr.push_back(ind + (shoe > 0)); ind += 2; } else { arr.push_back(saan[shoe].front()); saan[shoe].pop(); } } vector<ll> ex(300'005, 0); SegTree* sgt = new SegTree(0, 300'004, ex); for (ll i=N-1; i>=0;i--) { count += sgt->query(0, arr[i]-1); sgt->update(arr[i]); } return count; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccYiBOsn.o: in function `main':
grader.cpp:(.text.startup+0x289): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status