Submission #420722

# Submission time Handle Problem Language Result Execution time Memory
420722 2021-06-08T13:34:09 Z EJOI2019Andrew Ancient Books (IOI17_books) C++14
Compilation error
0 ms 0 KB
#include "books.h"

long long minimum_walk(std::vector<int> p, int s) {
	 map<int,int>v;
	  int n=p.size();
	  long long int a(0);
	  int c(0);
	  for(int i=0;i<n;++i)
      {
          a+=abs(i-p[i]);
          for(int j=min(i,p[i]);j<max(i,p[i]);++j)
            v[j]=1;
      }
      for(int i=0;i<n;++i)
      {
          if(!v[i])
            ++c;
          else
          {
              a+=2*c;
              c=0;
          }
      }
        
	return a;
}

Compilation message

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:4:3: error: 'map' was not declared in this scope
    4 |   map<int,int>v;
      |   ^~~
books.cpp:4:7: error: expected primary-expression before 'int'
    4 |   map<int,int>v;
      |       ^~~
books.cpp:10:14: error: 'abs' was not declared in this scope
   10 |           a+=abs(i-p[i]);
      |              ^~~
books.cpp:11:21: error: 'min' was not declared in this scope; did you mean 'std::min'?
   11 |           for(int j=min(i,p[i]);j<max(i,p[i]);++j)
      |                     ^~~
      |                     std::min
In file included from /usr/include/c++/10/vector:60,
                 from books.h:1,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: 'std::min' declared here
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
books.cpp:11:35: error: 'max' was not declared in this scope; did you mean 'std::max'?
   11 |           for(int j=min(i,p[i]);j<max(i,p[i]);++j)
      |                                   ^~~
      |                                   std::max
In file included from /usr/include/c++/10/vector:60,
                 from books.h:1,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
books.cpp:12:13: error: 'v' was not declared in this scope
   12 |             v[j]=1;
      |             ^
books.cpp:16:15: error: 'v' was not declared in this scope
   16 |           if(!v[i])
      |               ^