Submission #1114606

#TimeUsernameProblemLanguageResultExecution timeMemory
1114606lftroqArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h" typedef long long ll; const int N=100005; int n; queue<int> ql[N],qr[N]; int bit[N]; void update(int x,int v){for(;x;x-=(x&(-x))) bit[x]+=v;} int get(int x){int ans=0;for(;x<=n;x+=(x&(-x))) ans+=bit[x];return ans;} long long count_swaps(std::vector<int> s) { ll ans=0; n=(int)s.size(); for(int i=0;i<(int)s.size();i++) { if(s[i]<0) { s[i]*=-1; if(qr[s[i]].empty()) ql[s[i]].push(i+1); else { int x=qr[s[i]].front(); x+=get(x); //cout << i << ": " << x << ' ' << y << endl; ans+=i-x+1; update(i+1,1); update(x-1,-1); qr[s[i]].pop(); } } else { if(ql[s[i]].empty()) qr[s[i]].push(i+1); else { int x=ql[s[i]].front(); x+=get(x); //cout << i << ": " << x << ' ' << y << endl; ans+=i-x; update(i+1,1); update(x-1,-1); ql[s[i]].pop(); } } } return ans; }

Compilation message (stderr)

shoes.cpp:7:1: error: 'queue' does not name a type
    7 | queue<int> ql[N],qr[N];
      | ^~~~~
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:21:16: error: 'qr' was not declared in this scope
   21 |             if(qr[s[i]].empty()) ql[s[i]].push(i+1);
      |                ^~
shoes.cpp:21:34: error: 'ql' was not declared in this scope; did you mean 'll'?
   21 |             if(qr[s[i]].empty()) ql[s[i]].push(i+1);
      |                                  ^~
      |                                  ll
shoes.cpp:35:16: error: 'ql' was not declared in this scope; did you mean 'll'?
   35 |             if(ql[s[i]].empty()) qr[s[i]].push(i+1);
      |                ^~
      |                ll
shoes.cpp:35:34: error: 'qr' was not declared in this scope
   35 |             if(ql[s[i]].empty()) qr[s[i]].push(i+1);
      |                                  ^~