Submission #1292669

#TimeUsernameProblemLanguageResultExecution timeMemory
1292669MMihalevArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include<iostream> #include<vector> #include<queue> #include<set> #include "shoes.h" using namespace std; const int MAX_N=2e5+5; deque<int>pos[2][MAX_N]; int tree[MAX_N]; int N; void Update(int pos) { pos++; for(;;) { if(pos>N)break; tree[pos]++; pos+=((pos)&(-pos)); } } int Find(int pos) { int res=0; pos++; for(;;) { if(pos<1)break; res+=tree[pos]; pos-=((pos)&(-pos)); } return res; } bool ban[MAX_N]; long long count_swaps(std::vector<int> s) { N=s.size(); for(int i=0;i<s.size();i++) { if(s[i]<0)pos[0][-s[i]].push_back(i); else pos[1][s[i]].push_back(i); } long long ans=0; int cnt=0; for(int i=0;i<s.size();i++) { if(ban[i])continue; int wh=1-(s[i]<0 ? 0 : 1); int cur=pos[wh][abs(s[i])].front()-Find(pos[wh][abs(s[i])].front())+cnt-i-wh; ans+=cur; Update(pos[wh][abs(s[i])].front(),-1); cnt++; ban[pos[wh][abs(s[i])].front()]=1; pos[wh][abs(s[i])].pop_front(); pos[1-wh][abs(s[i])].pop_front(); } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:53:15: error: too many arguments to function 'void Update(int)'
   53 |         Update(pos[wh][abs(s[i])].front(),-1);
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shoes.cpp:11:6: note: declared here
   11 | void Update(int pos)
      |      ^~~~~~