/** - dwuy -
/> フ
| _ _|
/`ミ _x ノ
/ |
/ ヽ ?
/ ̄| | | |
| ( ̄ヽ__ヽ_)_)
\二つ
**/
#include <bits/stdc++.h>
#include "crocodile.h"
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define file(a) freopen(a".inp","r",stdin); freopen(a".out", "w",stdout)
#define fi first
#define se second
#define endl "\n"
#define len(s) (int)((s).size())
#define MASK(k)(1LL<<(k))
#define TASK "test"
using namespace std;
typedef tuple<int, int, int> tpiii;
typedef pair<double, double> pdd;
typedef pair<int, int> pii;
typedef long long ll;
const long long OO = 1e18;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MX = 100005;
int n, m;
int d[MX];
int cnt[MX];
vector<pii> G[MX];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
n = N;
m = M;
for(int i=0; i<m; i++){
int u = R[i][0] + 1;
int v = R[i][1] + 1;
int c = L[i];
G[u].push_back({v, c});
G[v].push_back({u, c});
}
priority_queue<pii, vector<pii>, greater<pii>> Q;
memset(d, 0x3f, sizeof d);
memset(cnt, 0, sizeof cnt);
for(int i=0; i<K; i++){
int u = P[i] + 1;
Q.push({0, u});
d[u] = 0;
cnt[u] = 1;
}
while(Q.size()){
int du, u;
tie(du, u) = Q.top();
Q.pop();
cnt[u]++;
if(cnt[u] != 2) continue;
if(u == 1) return d[u];
d[u] = du;
for(pii edge: G[u]){
int v, c;
tie(v, c) = edge;
if(cnt[v] < 2) Q.push({du + c, v});
}
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
3420 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
3420 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
3420 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |