Submission #146115

#TimeUsernameProblemLanguageResultExecution timeMemory
146115HellAngelArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 7; long long n, BIT[maxn]; queue<long long> q[maxn]; void Update(long long u, long long v) { for(; u < maxn; u += u & -u) BIT[u]+= v; } long long Get(long long u) { long long ans = 0; for(; u > 0; u -= u & -u) ans += BIT[u]; return ans; } long long count_swaps(vector<long long> vt) { long long ans = 0; n = vt.size() / 2; for(long long i = 0; i < n * 2; i++) { if(vt[i] > 0) { q[vt[i]].push(i); } Update(i + 1, 1); } long long cnt = 1; for(long long i = 0; i < n * 2; i++) { if(vt[i] < 0) { long long gau = Get(i + 1); ans += gau - cnt; cnt++; Update(1, 1); Update(i + 1, -1); long long posr = q[-vt[i]].front(); q[-vt[i]].pop(); long long meo = Get(posr + 1); ans += meo - cnt; cnt++; Update(1, 1); Update(posr + 1, -1); } } return ans; }

Compilation message (stderr)

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