/** - 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;
d[u] = du;
for(pii edge: G[u]){
int v, c;
tie(v, c) = edge;
Q.push({du + c, v});
}
}
return (d[1] == d[0]? -1 : d[1]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
3416 KB |
Output is correct |
2 |
Correct |
2 ms |
3420 KB |
Output is correct |
3 |
Correct |
2 ms |
3420 KB |
Output is correct |
4 |
Correct |
2 ms |
3420 KB |
Output is correct |
5 |
Correct |
2 ms |
3420 KB |
Output is correct |
6 |
Correct |
2 ms |
3420 KB |
Output is correct |
7 |
Correct |
4 ms |
3420 KB |
Output is correct |
8 |
Correct |
2 ms |
3484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
3416 KB |
Output is correct |
2 |
Correct |
2 ms |
3420 KB |
Output is correct |
3 |
Correct |
2 ms |
3420 KB |
Output is correct |
4 |
Correct |
2 ms |
3420 KB |
Output is correct |
5 |
Correct |
2 ms |
3420 KB |
Output is correct |
6 |
Correct |
2 ms |
3420 KB |
Output is correct |
7 |
Correct |
4 ms |
3420 KB |
Output is correct |
8 |
Correct |
2 ms |
3484 KB |
Output is correct |
9 |
Correct |
5 ms |
3932 KB |
Output is correct |
10 |
Correct |
1 ms |
3420 KB |
Output is correct |
11 |
Correct |
2 ms |
3752 KB |
Output is correct |
12 |
Correct |
6 ms |
4696 KB |
Output is correct |
13 |
Correct |
5 ms |
4444 KB |
Output is correct |
14 |
Correct |
2 ms |
3420 KB |
Output is correct |
15 |
Correct |
2 ms |
3608 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
3416 KB |
Output is correct |
2 |
Correct |
2 ms |
3420 KB |
Output is correct |
3 |
Correct |
2 ms |
3420 KB |
Output is correct |
4 |
Correct |
2 ms |
3420 KB |
Output is correct |
5 |
Correct |
2 ms |
3420 KB |
Output is correct |
6 |
Correct |
2 ms |
3420 KB |
Output is correct |
7 |
Correct |
4 ms |
3420 KB |
Output is correct |
8 |
Correct |
2 ms |
3484 KB |
Output is correct |
9 |
Correct |
5 ms |
3932 KB |
Output is correct |
10 |
Correct |
1 ms |
3420 KB |
Output is correct |
11 |
Correct |
2 ms |
3752 KB |
Output is correct |
12 |
Correct |
6 ms |
4696 KB |
Output is correct |
13 |
Correct |
5 ms |
4444 KB |
Output is correct |
14 |
Correct |
2 ms |
3420 KB |
Output is correct |
15 |
Correct |
2 ms |
3608 KB |
Output is correct |
16 |
Correct |
537 ms |
73092 KB |
Output is correct |
17 |
Correct |
67 ms |
13780 KB |
Output is correct |
18 |
Correct |
70 ms |
15316 KB |
Output is correct |
19 |
Correct |
554 ms |
75580 KB |
Output is correct |
20 |
Correct |
432 ms |
66804 KB |
Output is correct |
21 |
Correct |
28 ms |
8280 KB |
Output is correct |
22 |
Correct |
371 ms |
47312 KB |
Output is correct |