답안 #319914

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
319914 2020-11-06T18:37:30 Z knon0501 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
1040 ms 64840 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

int n;
vector<pair<int,int>> a[100001];
int b[100001];
int bb[100001];
int chk[100001];
int visit[100001];
int deg[100001];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    n=N;
    int i,j;

    for(i=0 ; i<M ; i++){
        int u=R[i][0];
        int v=R[i][1];
        a[u].push_back({v,L[i]});
        a[v].push_back({u,L[i]});
    }

    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> Q;

    for(i=0 ; i<K ; i++){
        Q.push({0,P[i]});
    }

    while(!Q.empty()){
        int v=Q.top().second;
        long long w=Q.top().first;
        Q.pop();

        if(visit[v])continue;
        visit[v]=1;
        for(auto k: a[v]){
            deg[k.first]++;
            long long d=w+k.second;
            if(d<=b[k.first] || deg[k.first]==1 ){
                bb[k.first]=b[k.first];
                b[k.first]=d;
            }
            else if(d<=bb[k.first] || deg[k.first]==2)
                bb[k.first]=d;
            if(deg[k.first]>=2)
            Q.push({bb[k.first],k.first});
        }
    }
    return bb[0];
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:16:11: warning: unused variable 'j' [-Wunused-variable]
   16 |     int i,j;
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 3 ms 2808 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 3 ms 2796 KB Output is correct
6 Correct 3 ms 2796 KB Output is correct
7 Correct 3 ms 2796 KB Output is correct
8 Correct 3 ms 2944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 3 ms 2808 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 3 ms 2796 KB Output is correct
6 Correct 3 ms 2796 KB Output is correct
7 Correct 3 ms 2796 KB Output is correct
8 Correct 3 ms 2944 KB Output is correct
9 Correct 5 ms 3200 KB Output is correct
10 Correct 3 ms 2796 KB Output is correct
11 Correct 4 ms 3072 KB Output is correct
12 Correct 8 ms 3308 KB Output is correct
13 Correct 7 ms 3308 KB Output is correct
14 Correct 3 ms 2796 KB Output is correct
15 Correct 3 ms 2928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 3 ms 2808 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 3 ms 2796 KB Output is correct
6 Correct 3 ms 2796 KB Output is correct
7 Correct 3 ms 2796 KB Output is correct
8 Correct 3 ms 2944 KB Output is correct
9 Correct 5 ms 3200 KB Output is correct
10 Correct 3 ms 2796 KB Output is correct
11 Correct 4 ms 3072 KB Output is correct
12 Correct 8 ms 3308 KB Output is correct
13 Correct 7 ms 3308 KB Output is correct
14 Correct 3 ms 2796 KB Output is correct
15 Correct 3 ms 2928 KB Output is correct
16 Correct 893 ms 64840 KB Output is correct
17 Correct 82 ms 14564 KB Output is correct
18 Correct 114 ms 16248 KB Output is correct
19 Correct 1040 ms 64060 KB Output is correct
20 Correct 558 ms 53796 KB Output is correct
21 Correct 44 ms 7908 KB Output is correct
22 Correct 540 ms 46308 KB Output is correct