Submission #857563

#TimeUsernameProblemLanguageResultExecution timeMemory
857563sleepntsheepArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include <vector> #include <cstdint> #include <iostream> #include <algorithm> #define N 200005 int fw[N], posraw[N<<1]; int *pos = posraw+N; void upd(int p, int k) { for (++p; p < N; p+=p&-p) fw[p] += k; } int qry(int p) { if(p<0)return 0;int z = 0; for (++p; p; p-=p&-p) z += fw[p]; return z; } int64_t count_swaps(std::vector<int> v) { int64_t z = 0; int n = v.size() >> 1, f = 0; for (int i = 0; i < (int)v.size(); ++i) pos[v[i]] = i; for (int i = 0; i < 2 * n; ++i, ++f) { if (qry(i) - qry(i-1) == 1) continue; int corresponding = pos[-v[i]] + (qry(2*n) - qry(pos[-v[i]])); z += corresponding - i*2 - 1 + (v[i] > 0); upd(pos[-v[i]], 1); } return z; } #if 1 int main() { std::cout << count_swaps({2, 1, -1, -2}); } #endif

Compilation message (stderr)

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