Submission #1104291

#TimeUsernameProblemLanguageResultExecution timeMemory
1104291KasymKCrocodile's Underground City (IOI11_crocodile)C++17
100 / 100
437 ms73144 KiB
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N = 1e5+5;
vector<pii> adj[N];
short int vis[N];
int dis[N];
 
int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]) {
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    for(int i = 0; i < m; ++i)
        adj[R[i][0]].pb({R[i][1], L[i]}), adj[R[i][1]].pb({R[i][0], L[i]});
    for(int i = 0; i < k; ++i)
        pq.push({0, P[i]}), vis[P[i]] = 1;
    while(!pq.empty()){
        int val = pq.top().ff, x = pq.top().ss;
        pq.pop();
        if(vis[x]==2)
            continue;
        vis[x]++;
        if(vis[x]==1)
            continue;
        dis[x] = val;
        tr(it, adj[x])
            if(vis[it->ff] != 2)
                pq.push({val+it->ss, it->ff});
    }
    return dis[0];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...