Submission #1264805

#TimeUsernameProblemLanguageResultExecution timeMemory
1264805hitsuujArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> #define pb push_back 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:25:17: error: 'queue' was not declared in this scope; did you mean 'std::queue'?
   25 |         map<int,queue<int>>q;
      |                 ^~~~~
      |                 std::queue
In file included from /usr/include/c++/11/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:86,
                 from shoes.cpp:2:
/usr/include/c++/11/bits/stl_queue.h:96:11: note: 'std::queue' declared here
   96 |     class queue
      |           ^~~~~
shoes.cpp:25:9: error: 'map' was not declared in this scope
   25 |         map<int,queue<int>>q;
      |         ^~~
shoes.cpp:25:9: note: suggested alternatives:
In file included from /usr/include/c++/11/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:81,
                 from shoes.cpp:2:
/usr/include/c++/11/bits/stl_map.h:100:11: note:   'std::map'
  100 |     class map
      |           ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:81,
                 from shoes.cpp:2:
/usr/include/c++/11/map:78:13: note:   'std::pmr::map'
   78 |       using map
      |             ^~~
shoes.cpp:25:13: error: expected primary-expression before 'int'
   25 |         map<int,queue<int>>q;
      |             ^~~
shoes.cpp:26:9: error: 'vector' was not declared in this scope
   26 |         vector<int>tan(n);
      |         ^~~~~~
shoes.cpp:26: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:26:16: error: expected primary-expression before 'int'
   26 |         vector<int>tan(n);
      |                ^~~
shoes.cpp:28:30: error: 'q' was not declared in this scope
   28 |         for(int i=0;i<n;i++) q[s[i]].push(i);
      |                              ^
shoes.cpp:29:26: error: 'q' was not declared in this scope
   29 |         for(auto [x,pos]:q){
      |                          ^
shoes.cpp:36:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   36 |                         tan[cur]=cnt;
      |                                ^
shoes.cpp:36:33: error: assignment of read-only location '*(tan + ((sizetype)cur))'
   36 |                         tan[cur]=cnt;
      |                         ~~~~~~~~^~~~
shoes.cpp:38:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   38 |                         tan[pas]=cnt;
      |                                ^
shoes.cpp:38:33: error: assignment of read-only location '*(tan + ((sizetype)pas))'
   38 |                         tan[pas]=cnt;
      |                         ~~~~~~~~^~~~
shoes.cpp:45:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   45 |         ans+=seek(tan[i]);
      |                        ^
shoes.cpp:45:24: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
   45 |         ans+=seek(tan[i]);
      |                   ~~~~~^
      |                        |
      |                        double (*)(double) noexcept
shoes.cpp:9:14: note:   initializing argument 1 of 'int seek(int)'
    9 | int seek(int x){
      |          ~~~~^
shoes.cpp:46:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   46 |         upd(tan[i]);
      |                  ^
shoes.cpp:46:18: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
   46 |         upd(tan[i]);
      |             ~~~~~^
      |                  |
      |                  double (*)(double) noexcept
shoes.cpp:17:14: note:   initializing argument 1 of 'void upd(int)'
   17 | void upd(int x){
      |          ~~~~^