Submission #537290

#TimeUsernameProblemLanguageResultExecution timeMemory
537290ERHArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> using namespace std; int lista[100000][2]; long long count_swaps(vector<int> v){ long long int total=0; for(int i=0; i<v.size(0); ++i){ int a=lista[i]; if(a<0){ a=-a; lista[a][1]=i+1; if(lista[a][0]){ total+=lista[a][1]-lista[a][0]; lista[a][1]=lista[a][0]=0; } } else { lista[a][0]=i+1; if(lista[a][1]){ total+=lista[a][0]-lista[a][1]-1; lista[a][1]=lista[a][0]=0; } } } return total; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:7:26: error: no matching function for call to 'std::vector<int>::size(int)'
    7 |   for(int i=0; i<v.size(0); ++i){
      |                          ^
In file included from /usr/include/c++/10/vector:67,
                 from shoes.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:918:7: note: candidate: 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
  918 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
/usr/include/c++/10/bits/stl_vector.h:918:7: note:   candidate expects 0 arguments, 1 provided
shoes.cpp:8:18: error: invalid conversion from 'int*' to 'int' [-fpermissive]
    8 |     int a=lista[i];
      |           ~~~~~~~^
      |                  |
      |                  int*