답안 #108391

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
108391 2019-04-29T04:46:23 Z PeppaPig 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
950 ms 84336 KB
#include "crocodile.h"
#include <bits/stdc++.h>

#define long long long
#define pii pair<long, long>
#define x first
#define y second

using namespace std;

const int N = 1e5+5;

int chk[N];
vector<pii> g[N];

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) {
    for(int i = 0; i < m; i++) {
        int a = r[i][0], b = r[i][1], c = l[i];
        g[a].emplace_back(b, c);
        g[b].emplace_back(a, c);
    }
    priority_queue<pii, vector<pii>, greater<pii> > Q;
    for(int i = 0; i < k; i++) {
        chk[p[i]] = 1;
        Q.emplace(0, p[i]);
    }
    while(!Q.empty()) {
        pii now = Q.top(); Q.pop();
        ++chk[now.y];
        if(chk[now.y] != 2) continue;
        if(!now.y) return now.x;
        for(pii v : g[now.y]) if(chk[v.x] < 2)
            Q.emplace(now.x + v.y, v.x); 
    }
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 5 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 4 ms 2816 KB Output is correct
5 Correct 6 ms 2816 KB Output is correct
6 Correct 5 ms 2816 KB Output is correct
7 Correct 5 ms 2816 KB Output is correct
8 Correct 6 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 5 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 4 ms 2816 KB Output is correct
5 Correct 6 ms 2816 KB Output is correct
6 Correct 5 ms 2816 KB Output is correct
7 Correct 5 ms 2816 KB Output is correct
8 Correct 6 ms 2816 KB Output is correct
9 Correct 6 ms 3200 KB Output is correct
10 Correct 4 ms 2660 KB Output is correct
11 Correct 6 ms 2816 KB Output is correct
12 Correct 10 ms 3840 KB Output is correct
13 Correct 9 ms 3456 KB Output is correct
14 Correct 5 ms 2816 KB Output is correct
15 Correct 5 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 5 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 4 ms 2816 KB Output is correct
5 Correct 6 ms 2816 KB Output is correct
6 Correct 5 ms 2816 KB Output is correct
7 Correct 5 ms 2816 KB Output is correct
8 Correct 6 ms 2816 KB Output is correct
9 Correct 6 ms 3200 KB Output is correct
10 Correct 4 ms 2660 KB Output is correct
11 Correct 6 ms 2816 KB Output is correct
12 Correct 10 ms 3840 KB Output is correct
13 Correct 9 ms 3456 KB Output is correct
14 Correct 5 ms 2816 KB Output is correct
15 Correct 5 ms 2816 KB Output is correct
16 Correct 817 ms 80744 KB Output is correct
17 Correct 98 ms 13560 KB Output is correct
18 Correct 174 ms 15836 KB Output is correct
19 Correct 950 ms 84336 KB Output is correct
20 Correct 367 ms 54776 KB Output is correct
21 Correct 46 ms 8316 KB Output is correct
22 Correct 450 ms 50416 KB Output is correct