#include "crocodile.h"
#include <bits/stdc++.h>
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(20) << (x)
#define all(v) (v).begin(), (v).end()
using namespace std;
#define forn(i,n) for (int i = 0; i < (n); ++i)
#define rforn(i, n) for(int i = (n) - 1;i >= 0;--i)
using ll = long long;
int mod = (ll)1e9 + 7;
#define PI acos(-1)
typedef pair<int, int> pairs;
const int INF = 1e9 + 100;
const int N = 2e5 + 100;
const double eps = 1e-7;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <typename XPAX>
void ckma(XPAX &x, XPAX y) {
x = (x < y ? y : x);
}
template <typename XPAX>
void ckmi(XPAX &x, XPAX y) {
x = (x > y ? y : x);
}
V<pairs> g[N];
int dis[N][2];
int travel_plan(int n, int m, int R[][2], int L[], int K, int P[])
{
memset(dis, INF, sizeof(dis));
forn(i, m) {
g[R[i][0]].emplace_back(R[i][1], L[i]);
g[R[i][1]].emplace_back(R[i][0], L[i]);
}
priority_queue<pairs, V<pairs>, greater<pairs>> q;
V<int> vis(n, 0);
V<bool> exit(N, false);
forn(i, K) {
q.emplace(0, P[i]);
exit[P[i]] = 1;
dis[P[i]][0] = dis[P[i]][1] = 0;
}
while(q.size()) {
auto [s, v] = q.top();
q.pop();
if(vis[v])continue;
++vis[v];
for(auto [i, w] : g[v]) {
int x = s + w;
if(exit[i])continue;
if(x < dis[i][0]) {
swap(dis[i][1], dis[i][0]);
dis[i][0] = x;
q.emplace(x, i);
}
else if(x < dis[i][1]) {
dis[i][1] = x;
q.emplace(x, i);
}
}
}
return dis[0][1];
}
Compilation message
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:52:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
52 | auto [s, v] = q.top();
| ^
crocodile.cpp:58:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
58 | for(auto [i, w] : g[v]) {
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
6476 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
6476 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
6476 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |