Submission #1054364

#TimeUsernameProblemLanguageResultExecution timeMemory
1054364GangstaRainforest Jumps (APIO21_jumps)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; const int N = 2e5 + 1; int dis[N]; bool sub1 = 0; vector <int> v[N]; priority_queue <int> pq; void dij(int x){ pq.push({0,x}); dis[x] = 0; while(!pq.empty()){ int a = pq.top().ss; pq.pop(); for(auto i: adj[a]){ if(dis[a] + i.ss < dis[i.ff]){ dis[i.ff] = dis[a] + i.ss; pq.push({-dis[i.ff],i.ff}); } } } } int minimum_jumps(int a, int b, int c, int d){ int mn = 1e9; for(int i = a; i <= b; i++){ for(int j = 1; j <= n; j++) dis[j] = 0; dij(i); for(int j = c; j <= d; j++) mn = min(mn,dis[j]); } return mn; } void init(int n, vector <int> h){ for(int i = 0; i < n; i++){ for(int j = i+1; j < n; j++){ if(h[j] > h[i]){ v[h[i]].pb(h[j]); break; } } for(int j = i-1; j >= 0; j--){ if(h[j] > h[i]){ v[h[i]].pb(h[j]); break; } } } } // int main(){ // int n, q; // vector <int> v; // cin >> n; // for(int i = 0; i < n; i++){ // int x; // cin >> x; // v.pb(x); // } // init(n, v); // cin >> q; // while(q--){ // int a, b, c, d; // cin >> a >> b >> c >> d; // } // }

Compilation message (stderr)

jumps.cpp: In function 'void dij(int)':
jumps.cpp:16:15: error: no matching function for call to 'std::priority_queue<int>::push(<brace-enclosed initializer list>)'
   16 |  pq.push({0,x});
      |               ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from jumps.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::less<int>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = int]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::less<int>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = int]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<int>::value_type&&' {aka 'int&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
jumps.cpp:19:20: error: request for member 'ss' in 'pq.std::priority_queue<int>::top()', which is of non-class type 'const value_type' {aka 'const int'}
   19 |   int a = pq.top().ss;
      |                    ^~
jumps.cpp:21:15: error: 'adj' was not declared in this scope
   21 |   for(auto i: adj[a]){
      |               ^~~
jumps.cpp:24:30: error: no matching function for call to 'std::priority_queue<int>::push(<brace-enclosed initializer list>)'
   24 |     pq.push({-dis[i.ff],i.ff});
      |                              ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from jumps.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::less<int>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = int]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::less<int>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = int]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<int>::value_type&&' {aka 'int&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
jumps.cpp: In function 'int minimum_jumps(int, int, int, int)':
jumps.cpp:33:23: error: 'n' was not declared in this scope
   33 |   for(int j = 1; j <= n; j++) dis[j] = 0;
      |                       ^