Submission #484142

#TimeUsernameProblemLanguageResultExecution timeMemory
484142vinnipuh01Rainforest Jumps (APIO21_jumps)C++17
Compilation error
0 ms0 KiB
#include "jumps.h" #include <bits/stdc++.h> #include <vector> int n; int a[ 200001 ]; vector <int> v[ 200001 ], vv; void init(int N, std::vector<int> H) { n = N; for ( int i = 0 ; i < H.size(); i ++ ) a[ i + 1 ] = H[ i ]; for ( int i = 1; i <= n; i ++ ) { while ( vv.size() && a[ vv.back() ] < a[ i ] ) { vv.pop_back(); } if ( vv.size() ) { v[ i ].push_back( vv.back() ); } vv.push_back( i ); } vv.clear(); for ( int i = n; i >= 1; i -- ) { while ( vv.size() && a[ vv.back() ] < a[ i ] ) { vv.pop_back(); } if ( vv.size() ) v[ i ].push_back( vv.back() ); vv.push_back( i ); } } const long long oo = 1e18; long long mx, mn; int c, f; long long int d[ 200001 ]; queue <int> q; int bfs( int u ) { for ( int i = 1; i <= n; i ++ ) d[ i ] = oo; d[ u ] = 0; q.push( u ); whiile ( q.size() ) { int g = q.front(); q.pop(); for ( auto to : v[ g ] ) { if ( d[ to ] > d[ g ] + 1 ) { d[ to ] = d[ g ] + 1; q.push( to ); } } } mx = oo; for ( int i = c; i <= f; i ++ ) { mx = min( mx, d[ i ] ); } return mx; } int minimum_jumps(int A, int B, int C, int D) { A ++; B ++; C ++; D ++; c = C; d = D; mn = oo; for ( int i = A; i <= B; i ++ ) { mn = min( mn, bfs( i ) ); } if ( mn == oo ) return -1; return mn; }

Compilation message (stderr)

jumps.cpp:7:1: error: 'vector' does not name a type
    7 | vector <int> v[ 200001 ], vv;
      | ^~~~~~
jumps.cpp: In function 'void init(int, std::vector<int>)':
jumps.cpp:11:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for ( int i = 0 ; i < H.size(); i ++ )
      |                    ~~^~~~~~~~~~
jumps.cpp:14:11: error: 'vv' was not declared in this scope
   14 |   while ( vv.size() && a[ vv.back() ] < a[ i ] ) {
      |           ^~
jumps.cpp:17:8: error: 'vv' was not declared in this scope
   17 |   if ( vv.size() ) {
      |        ^~
jumps.cpp:18:4: error: 'v' was not declared in this scope
   18 |    v[ i ].push_back( vv.back() );
      |    ^
jumps.cpp:20:3: error: 'vv' was not declared in this scope
   20 |   vv.push_back( i );
      |   ^~
jumps.cpp:22:2: error: 'vv' was not declared in this scope
   22 |  vv.clear();
      |  ^~
jumps.cpp:28:4: error: 'v' was not declared in this scope
   28 |    v[ i ].push_back( vv.back() );
      |    ^
jumps.cpp: At global scope:
jumps.cpp:37:1: error: 'queue' does not name a type; did you mean 'sigqueue'?
   37 | queue <int> q;
      | ^~~~~
      | sigqueue
jumps.cpp: In function 'int bfs(int)':
jumps.cpp:43:2: error: 'q' was not declared in this scope
   43 |  q.push( u );
      |  ^
jumps.cpp:44:2: error: 'whiile' was not declared in this scope
   44 |  whiile ( q.size() ) {
      |  ^~~~~~
jumps.cpp:56:8: error: 'min' was not declared in this scope; did you mean 'std::min'?
   56 |   mx = min( mx, d[ i ] );
      |        ^~~
      |        std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from jumps.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
jumps.cpp: In function 'int minimum_jumps(int, int, int, int)':
jumps.cpp:67:4: error: incompatible types in assignment of 'int' to 'long long int [200001]'
   67 |  d = D;
      |  ~~^~~
jumps.cpp:70:8: error: 'min' was not declared in this scope; did you mean 'std::min'?
   70 |   mn = min( mn, bfs( i ) );
      |        ^~~
      |        std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from jumps.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~