답안 #408841

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
408841 2021-05-19T17:52:21 Z SirCovidThe19th 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
564 ms 87508 KB
#include <bits/stdc++.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>>> 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<long long, int>> trav;
    vector<int> visited(n, 0);
    for (int i = 0; i < k; i++){
        visited[p[i]] = 1;
        trav.push({0, p[i]});
    }
    while (!trav.empty()){
        pair<long long, int> curr = trav.top(); trav.pop();
        visited[curr.second]++;
        if (visited[curr.second] == 2 and curr.second == 0) 
            return -curr.first;
        if (visited[curr.second] == 2)
            for (pair<int, int> elem : adj[curr.second])
                if (visited[elem.first] != 2)
                    trav.push({curr.first-elem.second, elem.first});
    }
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:5:41: warning: control reaches end of non-void function [-Wreturn-type]
    5 |     vector<vector<pair<int, int>>> adj(n);
      |                                         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 3 ms 644 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 6 ms 1104 KB Output is correct
13 Correct 4 ms 1228 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 3 ms 644 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 6 ms 1104 KB Output is correct
13 Correct 4 ms 1228 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 525 ms 87508 KB Output is correct
17 Correct 84 ms 13324 KB Output is correct
18 Correct 94 ms 14728 KB Output is correct
19 Correct 564 ms 75096 KB Output is correct
20 Correct 362 ms 63784 KB Output is correct
21 Correct 47 ms 5900 KB Output is correct
22 Correct 564 ms 45244 KB Output is correct