답안 #880377

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
880377 2023-11-29T09:01:29 Z MisterReaper 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
659 ms 77804 KB
#include <bits/stdc++.h>
using namespace std;

// [node cnt, edge cnt, edges, vals, exit cnt, exits]
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
    vector <pair <int, int>> adj[N];
    for(int i = 0; i < M; i++) {
        int u = R[i][0], v = R[i][1], w = L[i];
        adj[u].emplace_back(v, w);
        adj[v].emplace_back(u, w);
    }

    using T = pair <int, int>;
    priority_queue <T, vector <T>, greater <T>> pq;

    vector <int> cnt(N);
    vector <int> special(N);
    vector <int> ans(N, -1);

    for(int i = 0; i < K; i++) {
        int node = P[i];
        special[node] = true;
        pq.emplace(0, node);
    }

    while(!pq.empty()) {
        auto [c, node] = pq.top();
        pq.pop();

        cnt[node]++;
        if(special[node]) {
            if(cnt[node] != 1) {
                continue;
            }
        } else {
            if(cnt[node] != 2) {
                continue;
            }
        }

        ans[node] = c;
        for(auto [child, w] : adj[node]) {
            pq.emplace(c + w, child);
        }
    }

    return ans[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4548 KB Output is correct
4 Correct 1 ms 4440 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4548 KB Output is correct
4 Correct 1 ms 4440 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4552 KB Output is correct
9 Correct 3 ms 4952 KB Output is correct
10 Correct 1 ms 4544 KB Output is correct
11 Correct 2 ms 4700 KB Output is correct
12 Correct 6 ms 5212 KB Output is correct
13 Correct 5 ms 5212 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4548 KB Output is correct
4 Correct 1 ms 4440 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4552 KB Output is correct
9 Correct 3 ms 4952 KB Output is correct
10 Correct 1 ms 4544 KB Output is correct
11 Correct 2 ms 4700 KB Output is correct
12 Correct 6 ms 5212 KB Output is correct
13 Correct 5 ms 5212 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4496 KB Output is correct
16 Correct 600 ms 72392 KB Output is correct
17 Correct 63 ms 15952 KB Output is correct
18 Correct 89 ms 17188 KB Output is correct
19 Correct 659 ms 77804 KB Output is correct
20 Correct 474 ms 64528 KB Output is correct
21 Correct 33 ms 9300 KB Output is correct
22 Correct 423 ms 46756 KB Output is correct