Submission #1155450

#TimeUsernameProblemLanguageResultExecution timeMemory
1155450at128Arranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include "shoes.h" long long count_swaps(std::vector<int> s) { int n; n=s.size()/2; vector<int>v(2*n); map<int,set<int>>m; for(int i=0;i<2*n;i++){ v[i]=s[i]; m[v[i]].insert(i); } ll res=0,c=0; vector<int>s; for(int i=0;i<2*n;i++){ if(v[i]==INT_MAX){ continue; } if(v[i]>0){ int j=*m[-v[i]].begin(); v[j]=INT_MAX; int p1=(s.end()- lower_bound(all(s),i)); int p2=(s.end()- lower_bound(all(s),j)); s.pb(j); m[-v[i]].erase(m[-v[i]].begin()); res+=(j-i-(p2-p1)); debug(v[i],i,j,p2-p1,j-i-(p2-p1)-0); }else{ int j=*m[-v[i]].begin(); v[j]=INT_MAX; int p1=(s.end()-lower_bound(all(s),i)); int p2=(s.end()- lower_bound(all(s),j)); s.pb(j); m[-v[i]].erase(m[-v[i]].begin()); res+=(j-i-(p2-p1)-1); debug(v[i],i,j,p2-p1,j-i-(p2-p1)-1); } m[v[i]].erase(i); } cout<<res; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:6:5: error: 'vector' was not declared in this scope
    6 |     vector<int>v(2*n);
      |     ^~~~~~
shoes.cpp:6:5: 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:6:12: error: expected primary-expression before 'int'
    6 |     vector<int>v(2*n);
      |            ^~~
shoes.cpp:7:13: error: 'set' was not declared in this scope
    7 |     map<int,set<int>>m;
      |             ^~~
shoes.cpp:7:5: error: 'map' was not declared in this scope
    7 |     map<int,set<int>>m;
      |     ^~~
shoes.cpp:7:9: error: expected primary-expression before 'int'
    7 |     map<int,set<int>>m;
      |         ^~~
shoes.cpp:9:9: error: 'v' was not declared in this scope
    9 |         v[i]=s[i];
      |         ^
shoes.cpp:10:9: error: 'm' was not declared in this scope
   10 |         m[v[i]].insert(i);
      |         ^
shoes.cpp:12:5: error: 'll' was not declared in this scope
   12 |     ll res=0,c=0;
      |     ^~
shoes.cpp:13:12: error: expected primary-expression before 'int'
   13 |     vector<int>s;
      |            ^~~
shoes.cpp:15:12: error: 'v' was not declared in this scope
   15 |         if(v[i]==INT_MAX){
      |            ^
shoes.cpp:15:18: error: 'INT_MAX' was not declared in this scope
   15 |         if(v[i]==INT_MAX){
      |                  ^~~~~~~
shoes.cpp:2:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    1 | #include "shoes.h"
  +++ |+#include <climits>
    2 | 
shoes.cpp:18:12: error: 'v' was not declared in this scope
   18 |         if(v[i]>0){
      |            ^
shoes.cpp:19:20: error: 'm' was not declared in this scope
   19 |             int j=*m[-v[i]].begin();
      |                    ^
shoes.cpp:20:18: error: 'INT_MAX' was not declared in this scope
   20 |             v[j]=INT_MAX;
      |                  ^~~~~~~
shoes.cpp:20:18: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
shoes.cpp:21:42: error: 'all' was not declared in this scope; did you mean 'atoll'?
   21 |             int p1=(s.end()- lower_bound(all(s),i));
      |                                          ^~~
      |                                          atoll
shoes.cpp:21:30: error: 'lower_bound' was not declared in this scope; did you mean 'std::lower_bound'?
   21 |             int p1=(s.end()- lower_bound(all(s),i));
      |                              ^~~~~~~~~~~
      |                              std::lower_bound
In file included from /usr/include/c++/11/vector:62,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:2011:5: note: 'std::lower_bound' declared here
 2011 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
shoes.cpp:23:15: error: 'class std::vector<int>' has no member named 'pb'
   23 |             s.pb(j);
      |               ^~
shoes.cpp:25:13: error: 'res' was not declared in this scope
   25 |             res+=(j-i-(p2-p1));
      |             ^~~
shoes.cpp:26:13: error: 'debug' was not declared in this scope
   26 |             debug(v[i],i,j,p2-p1,j-i-(p2-p1)-0);
      |             ^~~~~
shoes.cpp:28:20: error: 'm' was not declared in this scope
   28 |             int j=*m[-v[i]].begin();
      |                    ^
shoes.cpp:29:18: error: 'INT_MAX' was not declared in this scope
   29 |             v[j]=INT_MAX;
      |                  ^~~~~~~
shoes.cpp:29:18: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
shoes.cpp:30:41: error: 'all' was not declared in this scope; did you mean 'atoll'?
   30 |             int p1=(s.end()-lower_bound(all(s),i));
      |                                         ^~~
      |                                         atoll
shoes.cpp:30:29: error: 'lower_bound' was not declared in this scope; did you mean 'std::lower_bound'?
   30 |             int p1=(s.end()-lower_bound(all(s),i));
      |                             ^~~~~~~~~~~
      |                             std::lower_bound
In file included from /usr/include/c++/11/vector:62,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:2011:5: note: 'std::lower_bound' declared here
 2011 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
shoes.cpp:32:15: error: 'class std::vector<int>' has no member named 'pb'
   32 |             s.pb(j);
      |               ^~
shoes.cpp:34:13: error: 'res' was not declared in this scope
   34 |             res+=(j-i-(p2-p1)-1);
      |             ^~~
shoes.cpp:35:13: error: 'debug' was not declared in this scope
   35 |             debug(v[i],i,j,p2-p1,j-i-(p2-p1)-1);
      |             ^~~~~
shoes.cpp:38:9: error: 'm' was not declared in this scope
   38 |         m[v[i]].erase(i);
      |         ^
shoes.cpp:38:11: error: 'v' was not declared in this scope
   38 |         m[v[i]].erase(i);
      |           ^
shoes.cpp:40:5: error: 'cout' was not declared in this scope
   40 |     cout<<res;
      |     ^~~~
shoes.cpp:40:11: error: 'res' was not declared in this scope
   40 |     cout<<res;
      |           ^~~
shoes.cpp:41:1: warning: no return statement in function returning non-void [-Wreturn-type]
   41 | }
      | ^