Submission #143162

#TimeUsernameProblemLanguageResultExecution timeMemory
143162mat_vArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> #define pb push_back using namespace std; long long n; vector<long long> tike[100005][2]; long long dokle[200005][2]; long long seg[400005]; long long lazy[400005]; bool bio[200005]; void init(long long l, long long r, long long ind){ if(l == r){ seg[ind] = l; return; } long long mid = (l + r) / 2; init(l, mid, ind * 2); init(mid + 1, r, ind * 2 + 1); } void propagate(long long l, long long r, long long ind){ if(lazy[ind] != 0){ seg[ind] -= (r - l + 1)*lazy[ind]; long long mid = (l + r) / 2; if(l != r){ lazy[ind * 2] = lazy[ind]; lazy[ind * 2 + 1] = lazy[ind]; } lazy[ind] = 0; } } long long query(long long l,long long r, long long ind, long long gde){ if(l == r)return seg[ind]; long long mid = (l + r)/2; if(gde <= mid)return query(l,mid,ind * 2, gde); else return query(mid + 1, r, ind * 2 + 1, gde); } void update(long long l, long long r, long long ind, long long levo, long long desno){ propagate(l,r,ind); if(levo >= l && desno <= r){ lazy[ind]++; propagate(l,r,ind); return; } if(desno < l || r < levo)return; long long mid = (l + r) / 2; update(l,mid,ind * 2,levo,desno); update(mid + 1,r,ind * 2 + 1,levo,desno); propagate(l,mid,ind*2); propagate(mid+1,r,ind*2+1); seg[ind] = seg[ind*2] + seg[ind*2+1]; propagate(l,r,ind); } long long count_swaps(std::vector<long long> s) { n = s.size()/2; for(long long i=0; i<2*n; i++){ if(s[i] < 0)tike[abs(s[i])][0].pb(i); else tike[s[i]][1].pb(i); } long long l = 0; long long shift = 0; init(0,2*n-1,1); long long res = 0; while(l < 2*n){ if(bio[l]){ l++; continue; } long long koji = abs(s[l]); long long ind; if(s[l] < 0)ind = 1; else ind = 0; long long gde = tike[koji][ind][dokle[koji][ind]]; bio[gde] = 1; dokle[koji][ind]++; dokle[koji][ind^1]++; long long pom = query(0,2*n-1,1,gde); //cout << pom << " " << gde << endl; if(gde != 2*n-1)update(0,2*n-1,1,gde+1,2*n-1); //bio[l + 1] = 1; res += (pom - l - 1); res += 1-ind; //cout << l << " " << pom << endl; //cout << l << " " << res << endl; l ++; } return res; }

Compilation message (stderr)

shoes.cpp: In function 'void propagate(long long int, long long int, long long int)':
shoes.cpp:25:19: warning: unused variable 'mid' [-Wunused-variable]
         long long mid = (l + r) / 2;
                   ^~~
shoes.cpp: In function 'long long int count_swaps(std::vector<long long int>)':
shoes.cpp:62:15: warning: unused variable 'shift' [-Wunused-variable]
     long long shift = 0;
               ^~~~~
/tmp/ccadnrzf.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