#include "crocodile.h"
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef pair<int, int> pii;
const int MAX = 101010, INF = 2e9;
int dist[MAX];
bool chk[MAX];
vector<pii> edge[MAX];
priority_queue<pii, vector<pii>, greater<pii>> pq;
pii operator+(const pii &a, const pii &b) {
return pii(a.va + b.va, a.vb + b.vb);
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for (int i=0; i<M; i++) {
edge[R[i][0]].push_back(pii(L[i], R[i][1]));
edge[R[i][1]].push_back(pii(L[i], R[i][0]));
}
for (int i=0; i<N; i++) dist[i] = INF;
for (int i=0; i<K; i++) {
dist[P[i]] = 0;
for (auto j : edge[P[i]]) pq.push(j);
}
while (!pq.empty()) {
pii tmp = pq.top();
pq.pop();
if (dist[tmp.vb] != INF) continue;
if (!chk[tmp.vb]) {
chk[tmp.vb] = true;
cout << "a" << tmp.va << ' ' << tmp.vb << '\n';
continue;
}
cout << "b" << tmp.va << ' ' << tmp.vb << '\n';
dist[tmp.vb] = tmp.va;
for (auto i : edge[tmp.vb]) pq.push(i+pii(tmp.va, 0));
}
return dist[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
2680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
2680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
2680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |