Submission #1264803

#TimeUsernameProblemLanguageResultExecution timeMemory
1264803hitsuujArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include "shoes.h" #include <vector> #include <map> #include <queue> 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:24:17: error: 'queue' was not declared in this scope; did you mean 'std::queue'?
   24 |         map<int,queue<int>>q;
      |                 ^~~~~
      |                 std::queue
In file included from /usr/include/c++/11/queue:64,
                 from shoes.cpp:4:
/usr/include/c++/11/bits/stl_queue.h:96:11: note: 'std::queue' declared here
   96 |     class queue
      |           ^~~~~
shoes.cpp:24:9: error: 'map' was not declared in this scope
   24 |         map<int,queue<int>>q;
      |         ^~~
shoes.cpp:24:9: note: suggested alternatives:
In file included from /usr/include/c++/11/map:61,
                 from shoes.cpp:3:
/usr/include/c++/11/bits/stl_map.h:100:11: note:   'std::map'
  100 |     class map
      |           ^~~
In file included from shoes.cpp:3:
/usr/include/c++/11/map:78:13: note:   'std::pmr::map'
   78 |       using map
      |             ^~~
shoes.cpp:24:13: error: expected primary-expression before 'int'
   24 |         map<int,queue<int>>q;
      |             ^~~
shoes.cpp:25:9: error: 'vector' was not declared in this scope
   25 |         vector<int>tan(n);
      |         ^~~~~~
shoes.cpp:25: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:25:16: error: expected primary-expression before 'int'
   25 |         vector<int>tan(n);
      |                ^~~
shoes.cpp:27:30: error: 'q' was not declared in this scope
   27 |         for(int i=0;i<n;i++) q[s[i]].push(i);
      |                              ^
shoes.cpp:28:26: error: 'q' was not declared in this scope
   28 |         for(auto [x,pos]:q){
      |                          ^
shoes.cpp:35:25: error: 'tan' was not declared in this scope
   35 |                         tan[cur]=cnt;
      |                         ^~~
shoes.cpp:44:19: error: 'tan' was not declared in this scope
   44 |         ans+=seek(tan[i]);
      |                   ^~~