Submission #303822

#TimeUsernameProblemLanguageResultExecution timeMemory
303822noob_c0deArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ar array const int mxn=2e5+3; int n; vector<int> pos[mxn],neg[mxn]; int ft[2*mxn]; int vis[mxn]; void upd(int u,int d) { while(u<=n) { ft[u]+=d; u+=u&-u; } } int get(int u) { int res=0; while(u) { res+=ft[u]; u-=u&-u; } return res; } int count_swaps(vector<int> a) { n=a.size(); for (int i=n;i>=1;i++) { if (a[i]>0) pos[a[i-1]].push_back(i); else neg[-a[i-1]].push_back(i); } int ans=0; for (int i=1;i<=n;i++) if (!vis[i]) { int vt; if (a[i-1]>0) vt=neg[a[i-1]].back(); else vt=pos[-a[i-1]].back(); pos[abs(a[i-1])].pop_back(); neg[abs(a[i-1])].pop_back(); ans+=(vt+get(vt))-(i+get(i))-1; if (a[i-1]>0) ans++; upd(1,1); if (vt+1<=n) upd(vt+1,-1); vis[vt]=1; } return(ans); }

Compilation message (stderr)

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