답안 #989695

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
989695 2024-05-28T15:05:34 Z vjudge2 악어의 지하 도시 (IOI11_crocodile) C++17
0 / 100
1 ms 4444 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int, int>

const ll INF = 1e18;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
    vector<vector<pii>> adj(N);
    for (int i = 0; i < M; i++) {
        adj[R[i][0]].push_back({R[i][1], L[i]});
        adj[R[i][1]].push_back({R[i][0], L[i]});
    }
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<>> q;
    vector<int> cnt(N, 0);
    vector<ll> di(N, INF);
    for (int i = 0; i < K; i++) {
        cnt[P[i]] = 2, di[P[i]] = 0;
        q.push({0, P[i]});
    }
    while (!q.empty()) {
        auto [dist, u] = q.top();
        q.pop();
        cnt[u]++;
        if (cnt[u] == 2) di[u] = dist;
        if (cnt[u] < 2 || (cnt[u] >= 2 && di[u] != dist)) continue;
        for (auto& [v, w] : adj[u]) {
            q.push({di[u] + w, v});
        }
    }
    return di[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Incorrect 1 ms 4444 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Incorrect 1 ms 4444 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Incorrect 1 ms 4444 KB Output isn't correct
6 Halted 0 ms 0 KB -