Submission #1347653

#TimeUsernameProblemLanguageResultExecution timeMemory
1347653jumpJakarta Skyscrapers (APIO15_skyscraper)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define int long long
int b[30010];
int p[30010];
std::vector<std::pair<int,int>> adj[30010];
int dist[30010];
signed main() {
	int n,m;
	std::cin >> n >> m;
	int s=0,e=1;
	for(int i=0;i<m;i++){
		std::cin >> b[i] >> p[i];
		if(i==0)s=b[i];
		else if(i==1)e=b[i];
	}
	for(int i=0;i<n;i++){
		dist[i]=1e18;
	}
	std::priority_queue<std::pair<int,int>> pq;
	pq.push({-0,s});
	while(!pq.empty()){
		int weight=-pq.top().first;
		int node=pq.top().second;
		pq.pop();
		for(int j=b[i];j<n;j+=p[i]){
			int w=(j-b[i])/p[i];
			if(weight+w<dist[to]){
				dist[to]=weight+w;
				pq.push({-(dist[to]),to});
			}
		}
		for(int j=b[i]-p[i];j>=0;j-=p[i]){
			int w=(b[i]-j)/p[i];
			if(weight+w<dist[to]){
				dist[to]=weight+w;
				pq.push({-(dist[to]),to});
			}
		}
	}
	if(dist[e]>=1e18)dist[e]=-1;
	std::cout << dist[e];
}

Compilation message (stderr)

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:25:29: error: 'i' was not declared in this scope
   25 |                 for(int j=b[i];j<n;j+=p[i]){
      |                             ^
skyscraper.cpp:27:42: error: 'to' was not declared in this scope; did you mean 'tm'?
   27 |                         if(weight+w<dist[to]){
      |                                          ^~
      |                                          tm
skyscraper.cpp:29:40: error: no matching function for call to 'std::priority_queue<std::pair<long long int, long long int> >::push(<brace-enclosed initializer list>)'
   29 |                                 pq.push({-(dist[to]),to});
      |                                 ~~~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:157,
                 from skyscraper.cpp:1:
/usr/include/c++/13/bits/stl_queue.h:738:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = std::less<std::pair<long long int, long long int> >; value_type = std::pair<long long int, long long int>]'
  738 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:738:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<std::pair<long long int, long long int> >::value_type&' {aka 'const std::pair<long long int, long long int>&'}
  738 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_queue.h:746:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = std::less<std::pair<long long int, long long int> >; value_type = std::pair<long long int, long long int>]'
  746 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:746:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
  746 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
skyscraper.cpp:32:29: error: 'i' was not declared in this scope
   32 |                 for(int j=b[i]-p[i];j>=0;j-=p[i]){
      |                             ^
skyscraper.cpp:34:42: error: 'to' was not declared in this scope; did you mean 'tm'?
   34 |                         if(weight+w<dist[to]){
      |                                          ^~
      |                                          tm
skyscraper.cpp:36:40: error: no matching function for call to 'std::priority_queue<std::pair<long long int, long long int> >::push(<brace-enclosed initializer list>)'
   36 |                                 pq.push({-(dist[to]),to});
      |                                 ~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_queue.h:738:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = std::less<std::pair<long long int, long long int> >; value_type = std::pair<long long int, long long int>]'
  738 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:738:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<std::pair<long long int, long long int> >::value_type&' {aka 'const std::pair<long long int, long long int>&'}
  738 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_queue.h:746:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = std::less<std::pair<long long int, long long int> >; value_type = std::pair<long long int, long long int>]'
  746 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:746:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
  746 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~