#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MASK(i) (1ULL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ll mask){return __builtin_popcountll(mask);}
int ctz(ull mask){return __builtin_ctzll(mask);}
int logOf(ull mask){return 63 - __builtin_clzll(mask);}
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}
template <class T1, class T2>
bool maximize(T1 &a, T2 b){
if (a < b) {a = b; return true;}
return false;
}
template <class T1, class T2>
bool minimize(T1 &a, T2 b){
if (a > b) {a = b; return true;}
return false;
}
template <class T>
void printArr(T& container, string separator = " ", string finish = "\n", ostream &out = cout){
for(auto item: container) out << item << separator;
out << finish;
}
template <class T>
void remove_dup(vector<T> &a){
sort(ALL(a));
a.resize(unique(ALL(a)) - a.begin());
}
struct P{
int i; ll w;
P(){}
P(int _i, ll _w){i = _i, w = _w;}
};
struct compare{
bool operator () (P a, P b){return a.w > b.w;}
};
const int N = 1e5 + 69;
const ll INF = 1e18 + 69;
vector<P> graph[N];
int travel_plan(int n, int m, int R[][2], int L[], int K, int E[]){
for(int i = 0; i<m; ++i){
int u = R[i][0], v = R[i][1];
ll w = L[i];
graph[u].push_back(P(v, w));
graph[v].push_back(P(u, w));
}
priority_queue<P, vector<P>, compare> pq;
vector<ll> dis(n, INF);
for(int i = 0; i<K; ++i){
int u = E[i];
pq.push(P(u, 0));
dis[u] = 0;
}
while(pq.size()){
P u = pq.top(); pq.pop();
for(P v: graph[u.i]) if (minimize(dis[v.i], dis[u.i] + v.w))
pq.push(P(v.i, dis[v.i]));
}
ll ans = 0;
int u = 0;
while(dis[u] > 0){
vector<pair<P, ll>> kost;
for(P v: graph[u]) kost.push_back({v, dis[v.i] + v.w});
sort(ALL(kost), [](pair<P, ll> a, pair<P, ll> b){return a.second < b.second;});
P the_one = kost[1].first;
ans += the_one.w;
u = the_one.i;
}
return ans;
}
// int main(void){
// ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// return 0;
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2051 ms |
6748 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2051 ms |
6748 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2051 ms |
6748 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |