Submission #484143

#TimeUsernameProblemLanguageResultExecution timeMemory
484143vinnipuh01밀림 점프 (APIO21_jumps)C++17
Compilation error
0 ms0 KiB
#include "jumps.h"

#include <bits/stdc++.h>
#include <vector>

using namespace std;
int n;
int a[ 200001 ];
vector <int> v[ 200001 ], vv;

void init(int N, 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: In function 'void init(int, std::vector<int>)':
jumps.cpp:13:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for ( int i = 0 ; i < H.size(); i ++ )
      |                    ~~^~~~~~~~~~
jumps.cpp: In function 'int bfs(int)':
jumps.cpp:46:2: error: 'whiile' was not declared in this scope
   46 |  whiile ( q.size() ) {
      |  ^~~~~~
jumps.cpp: In function 'int minimum_jumps(int, int, int, int)':
jumps.cpp:69:4: error: incompatible types in assignment of 'int' to 'long long int [200001]'
   69 |  d = D;
      |  ~~^~~
jumps.cpp:72:26: error: no matching function for call to 'min(long long int&, int)'
   72 |   mn = min( mn, bfs( i ) );
      |                          ^
In file included from /usr/include/c++/10/vector:60,
                 from jumps.h:1,
                 from jumps.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
jumps.cpp:72:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   72 |   mn = min( mn, bfs( i ) );
      |                          ^
In file included from /usr/include/c++/10/vector:60,
                 from jumps.h:1,
                 from jumps.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
jumps.cpp:72:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   72 |   mn = min( mn, bfs( i ) );
      |                          ^
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:3:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
jumps.cpp:72:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   72 |   mn = min( mn, bfs( i ) );
      |                          ^
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:3:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
jumps.cpp:72:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   72 |   mn = min( mn, bfs( i ) );
      |                          ^