#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
struct Data{
int vertex;
pair<ll, ll>value;
Data(int vertex, pair<ll, ll>value){
this->vertex = vertex;
this->value = value;
}
friend bool operator <(const Data a, const Data b){
return a.value > b.value;
}
};
template<class T>bool minimize(T& a, T b){
if(a > b){
a = b;
return true;
}
return false;
}
const int lim = 1e5 + 5;
int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]){
vector<int>deg(n, 0);
vector<vector<int>>e(n);
vector<pair<ll, ll>>dp(n, make_pair(INF, INF));
for(int i = 0; i < m; i++){
e[R[i][0]].emplace_back(i);
e[R[i][1]].emplace_back(i);
}
priority_queue<Data>pq;
for(int i = 0; i < k; i++){
pq.emplace(P[i], dp[P[i]] = make_pair(0, 0));
}
while(!pq.empty()){
auto [u, W] = pq.top();
pq.pop();
if(W == dp[u]){
for(int i = 0; i < e[u].size(); i++){
int v = R[e[u][i]][0] ^ R[e[u][i]][1] ^ u;
ll w = W.second + L[e[u][i]];
if(minimize(dp[v], make_pair(w, dp[v].first)) || minimize(dp[v], make_pair(dp[v].first, w))){
pq.emplace(v, dp[v]);
}
}
}
}
return dp[0].second;
}
Compilation message
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:38:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
38 | auto [u, W] = pq.top();
| ^
crocodile.cpp:41:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for(int i = 0; i < e[u].size(); i++){
| ~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4440 KB |
Output is correct |
3 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4440 KB |
Output is correct |
3 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4440 KB |
Output is correct |
3 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |