답안 #976537

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
976537 2024-05-06T16:34:52 Z marinaluca 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
414 ms 72256 KB
#include <bits/stdc++.h>
#include "crocodile.h"

using namespace std;
int travel_plan(int N, int M, int R[][2], int L[], int k, int P[]){
    vector <vector<pair<int, int>>> ans(N);
    for (int i = 0; i < M; ++ i){
        int a = R[i][0], b = R[i][1];
        ans[a].emplace_back(b, L[i]);
        ans[b].emplace_back(a, L[i]);
    }
    vector <int> v(N);
    priority_queue<pair<int, int>> pq;
    for (int i = 0; i < k; ++ i){
        v[P[i]] ++; 
        pq.emplace(0, P[i]);
    }
    while (!pq.empty()){
        auto [x, y] = pq.top();
        pq.pop();
        if (v[y] ++ == 1){
            if (y == 0)
                return -x;
            for (auto &[xx, yy] : ans[y]){
                pq.emplace(x - yy, xx);
            }
        }
    }
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:6:42: warning: control reaches end of non-void function [-Wreturn-type]
    6 |     vector <vector<pair<int, int>>> ans(N);
      |                                          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
9 Correct 3 ms 4808 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 2 ms 4568 KB Output is correct
12 Correct 5 ms 5212 KB Output is correct
13 Correct 3 ms 5208 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
9 Correct 3 ms 4808 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 2 ms 4568 KB Output is correct
12 Correct 5 ms 5212 KB Output is correct
13 Correct 3 ms 5208 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4552 KB Output is correct
16 Correct 349 ms 72256 KB Output is correct
17 Correct 72 ms 15188 KB Output is correct
18 Correct 82 ms 16468 KB Output is correct
19 Correct 381 ms 69132 KB Output is correct
20 Correct 243 ms 65164 KB Output is correct
21 Correct 39 ms 9020 KB Output is correct
22 Correct 414 ms 46500 KB Output is correct