Submission #981309

#TimeUsernameProblemLanguageResultExecution timeMemory
981309Faisal_Saqib밀림 점프 (APIO21_jumps)C++17
Compilation error
0 ms0 KiB
#include "jumps.h" #include <vector> #include <bits/stdc++.h> //#include "stub.cpp" using namespace std; const int N=2e5+2; int n; int dist[N]; vector<int> adj[N]; bool subtask1=0; void init(int NP, std::vector<int> a) { subtask1=is_sorted(begin(a),end(a)); n=NP; set<int> spl; vector<pair<int,int>> pp; for(int j=0;j<n;j++) pp.push_back({h[j],j}); sort(begin(pp),end(pp)); for(int j=n-1;j>=0;j--) { auto it = spl.upper_bound(pp[j].second); // cout<<"For "<<pp[j].second<<" edge with: "; if(it!=end(spl)) { // cout<<*it<<' '; adj[pp[j].second].push_back(*it); } if(it!=begin(spl)) { it--; // cout<<*it<<' '; adj[pp[j].second].push_back(*it); } // cout<<endl; spl.insert(pp[j].second); } } int minimum_jumps(int a, int b, int c, int d) { if(subtask1) { return max(0,c-b); } for(int j=0;j<=n;j++) dist[j]=2e9; priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq; for(int st=a;st<=b;st++) pq.push({dist[st]=0,st}); while(pq.size()) { auto it=pq.top(); if(c<=it.second and it.second<=d) return it.first; pq.pop(); if(dist[it.second]==it.first) for(auto dj:adj[it.second]) if(dist[dj]>(dist[it.second]+1)) { dist[dj]=dist[it.second]+1; pq.push({dist[dj],dj}); } } return -1; }

Compilation message (stderr)

jumps.cpp: In function 'void init(int, std::vector<int>)':
jumps.cpp:22:19: error: 'h' was not declared in this scope
   22 |     pp.push_back({h[j],j});
      |                   ^
jumps.cpp:22:26: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   22 |     pp.push_back({h[j],j});
      |                          ^
In file included from /usr/include/c++/10/vector:67,
                 from jumps.h:1,
                 from jumps.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~