Submission #870772

#TimeUsernameProblemLanguageResultExecution timeMemory
870772tien9d2Arranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define int long long #define ll pair<int,int> using namespace std; const int N=100001; int base=100001; vector<int> vt[N*2]; int k[N*2];////xét đến cái thứ bao nhiêu của vector vt :D int tree[N*8]; void update(int s,int l,int r,int u,int kk) { if ((l>r) or (l>u) or (r<u)) { return; } if (l==r) { tree[s]+=kk; return; } int mid=(l+r)>>1; update(s*2,l,mid,u,kk); update(s*2+1,mid+1,r,u,kk); tree[s]=tree[s*2]+tree[s*2+1]; } int getval(int s,int l,int r,int u,int v) { if ((l>r) or (l>v) or (r<u)) return 0; if ((u<=l) and (r<=v)) { return tree[s]; } int mid=(l+r)>>1; return getval(s*2,l,mid,u,v)+getval(s*2+1,mid+1,r,u,v); } int64_t count_swap(vector<int> S) { // freopen("COCKTAIL.INP","r",stdin); // freopen("COCKTAIL.OUT","w",stdout); ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n=S.size(); // cin >> n; for (int i=1;i<=n*2;i++) { // cin >> a[i]; vt[S[i-1]+base].push_back(i); } for (int i=1;i<=n*2;i++) { update(1,1,n*2,i,1); } long long kq=0; //long long bef=0; for (int i=1;i<=n*2;i++) { if (S[i-1]>0) { int kk=0-S[i-1]+base; int i2=vt[kk][k[kk]]; k[kk]++; if (i<i2) kq+=getval(1,1,n*2,i,i2)-1; else kq+=getval(1,1,n*2,i2,i)-2; update(1,1,n*2,i2,-1); update(1,1,n*2,i,1); //cout << i2 << " " << kq-bef << '\n'; //bef=kq; } } //cout << kq; return kq; }

Compilation message (stderr)

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