Submission #1346981

#TimeUsernameProblemLanguageResultExecution timeMemory
1346981Born_To_Laugh악어의 지하 도시 (IOI11_crocodile)C++17
100 / 100
222 ms84092 KiB
// Born_To_Laugh - Hughie Do
#include "crocodile.h"
#include <bits/stdc++.h>
#define alle(AC) AC.begin(), AC.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
[[maybe_unused]] const int MOD = 998244353, INF = 1e9 + 7;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
    vector<vector<pair<int, ll>>> adj(N);
    for (int i = 0; i < M; i++) {
        int u = R[i][0];
        int v = R[i][1];
        ll w = L[i];
        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }
    vector<int> vis(N, 0);
    
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<>> pq;
    for (int i = 0; i < K; i++) {
        vis[P[i]] = 1;
        pq.push({0, P[i]});
    }

    while (!pq.empty()) {
        ll d = pq.top().first;
        int u = pq.top().second;
        pq.pop();
        
        vis[u]++;
        if (vis[u] > 2) continue;
        else if (vis[u] == 1) continue;

        if (u == 0) return d;
        for (auto edge : adj[u]) {
            int v = edge.first;
            ll w = edge.second;
            if (vis[v] < 2) {
                pq.push({d + w, v});
            }
        }
    }
}

Compilation message (stderr)

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:45:1: warning: control reaches end of non-void function [-Wreturn-type]
   45 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...