답안 #272748

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
272748 2020-08-18T15:03:57 Z toonewbie 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
670 ms 88736 KB
#include <bits/stdc++.h>
#include "crocodile.h"

using namespace std;

const int N = 100005;

vector <pair <int, int>> g[N];
int used[N];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
    for (int i = 0; i < M; i++) {
        g[R[i][0]].push_back({R[i][1], L[i]});
        g[R[i][1]].push_back({R[i][0], L[i]});
    }
    priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq;
    for (int i = 0; i < K; i++) {
        pq.push({0, P[i]});
        used[P[i]] = 1;
    }
    while(!pq.empty()) {
        auto cur = pq.top(); pq.pop();
        long long d = cur.first; int v = cur.second;
        if (++used[v] != 2) continue;
        if (v == 0) {
            return d;
        }
        for (auto i : g[v]) {
            pq.push({d + i.second, i.first});
        }
    }
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:16:103: warning: control reaches end of non-void function [-Wreturn-type]
   16 |     priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq;
      |                                                                                                       ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 4 ms 2816 KB Output is correct
5 Correct 3 ms 2816 KB Output is correct
6 Correct 4 ms 2816 KB Output is correct
7 Correct 3 ms 2816 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 4 ms 2816 KB Output is correct
5 Correct 3 ms 2816 KB Output is correct
6 Correct 4 ms 2816 KB Output is correct
7 Correct 3 ms 2816 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
9 Correct 4 ms 3200 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 5 ms 2944 KB Output is correct
12 Correct 8 ms 3840 KB Output is correct
13 Correct 5 ms 3200 KB Output is correct
14 Correct 3 ms 2688 KB Output is correct
15 Correct 4 ms 2944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 4 ms 2816 KB Output is correct
5 Correct 3 ms 2816 KB Output is correct
6 Correct 4 ms 2816 KB Output is correct
7 Correct 3 ms 2816 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
9 Correct 4 ms 3200 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 5 ms 2944 KB Output is correct
12 Correct 8 ms 3840 KB Output is correct
13 Correct 5 ms 3200 KB Output is correct
14 Correct 3 ms 2688 KB Output is correct
15 Correct 4 ms 2944 KB Output is correct
16 Correct 645 ms 88736 KB Output is correct
17 Correct 106 ms 13432 KB Output is correct
18 Correct 114 ms 14840 KB Output is correct
19 Correct 670 ms 75228 KB Output is correct
20 Correct 326 ms 49656 KB Output is correct
21 Correct 52 ms 7544 KB Output is correct
22 Correct 639 ms 46964 KB Output is correct