Submission #1264802

#TimeUsernameProblemLanguageResultExecution timeMemory
1264802hitsuujArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include "shoes.h" const int lim=1e5; int n; int tri[lim+10]; int seek(int x){ int res=0; while(x<=n){ res+=tri[x]; x+=x&-x; } return res; } void upd(int x){ while(x>0){ tri[x]++; x-=x&-x; } } long long count_swaps(std::vector<int> s) { n=s.size(); map<int,queue<int>>q; vector<int>tan(n); int cnt=1; for(int i=0;i<n;i++) q[s[i]].push(i); for(auto [x,pos]:q){ if(x>0) break; while(pos.size()){ int cur=pos.front(); pos.pop(); int pas=q[-s[cur]].front(); q[-s[cur]].pop(); tan[cur]=cnt; cnt++; tan[pas]=cnt; cnt++; } } int ans=0; for(int i=0;i<n;i++){ ans+=seek(tan[i]); upd(tan[i]); } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:21:17: error: 'queue' was not declared in this scope
   21 |         map<int,queue<int>>q;
      |                 ^~~~~
shoes.cpp:21:9: error: 'map' was not declared in this scope
   21 |         map<int,queue<int>>q;
      |         ^~~
shoes.cpp:21:13: error: expected primary-expression before 'int'
   21 |         map<int,queue<int>>q;
      |             ^~~
shoes.cpp:22:9: error: 'vector' was not declared in this scope
   22 |         vector<int>tan(n);
      |         ^~~~~~
shoes.cpp:22:9: note: suggested alternatives:
In file included from /usr/include/c++/11/vector:67,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/11/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
shoes.cpp:22:16: error: expected primary-expression before 'int'
   22 |         vector<int>tan(n);
      |                ^~~
shoes.cpp:24:30: error: 'q' was not declared in this scope
   24 |         for(int i=0;i<n;i++) q[s[i]].push(i);
      |                              ^
shoes.cpp:25:26: error: 'q' was not declared in this scope
   25 |         for(auto [x,pos]:q){
      |                          ^
shoes.cpp:32:25: error: 'tan' was not declared in this scope
   32 |                         tan[cur]=cnt;
      |                         ^~~
shoes.cpp:41:19: error: 'tan' was not declared in this scope
   41 |         ans+=seek(tan[i]);
      |                   ^~~