답안 #113057

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
113057 2019-05-23T13:09:01 Z oolimry 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
1239 ms 91304 KB
#include <bits/stdc++.h>
using namespace std;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    int n = N;
    int m = M;
    typedef pair<long long, long long> ii;
    const long long inf = 10234567890123456ll;

    ii value[n];
    fill(value, value + n, ii(inf,inf));

    for(int i = 0;i < K;i++){
        value[P[i]] = ii(0,0);
    }

    multiset<ii> s;
    for(int i = 0;i < N;i++){
        s.insert(ii(value[i].second, i));
    }

    vector<ii> adj[n];
    for(int i = 0;i < m;i++){
        int a = R[i][0];
        int b = R[i][1];
        adj[a].push_back(ii(b,L[i]));
        adj[b].push_back(ii(a,L[i]));
    }



    while(!s.empty()){
        int u = s.begin()->second;
        s.erase(s.begin());
        long long x = value[u].second;
        for(int i = 0;i < adj[u].size();i++){
            int v = adj[u][i].first;
            long long y = adj[u][i].second;
            if(x + y < value[v].second){
                //cout << u << " " << v << "\n";
                s.erase(s.find(ii(value[v].second, v)));
                if(x + y < value[v].first){
                    value[v].second = value[v].first;
                    value[v].first = x + y;
                }
                else{
                    value[v].second = x + y;
                }
                s.insert(ii(value[v].second, v));
            }

        }
    }


    return value[0].second;
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:36:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0;i < adj[u].size();i++){
                       ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 356 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 552 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 3 ms 512 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 356 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 552 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 3 ms 512 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 4 ms 896 KB Output is correct
10 Correct 3 ms 356 KB Output is correct
11 Correct 4 ms 512 KB Output is correct
12 Correct 6 ms 1024 KB Output is correct
13 Correct 5 ms 1152 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 356 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 552 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 3 ms 512 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 4 ms 896 KB Output is correct
10 Correct 3 ms 356 KB Output is correct
11 Correct 4 ms 512 KB Output is correct
12 Correct 6 ms 1024 KB Output is correct
13 Correct 5 ms 1152 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 512 KB Output is correct
16 Correct 813 ms 81736 KB Output is correct
17 Correct 149 ms 23988 KB Output is correct
18 Correct 222 ms 26504 KB Output is correct
19 Correct 1239 ms 91304 KB Output is correct
20 Correct 332 ms 65572 KB Output is correct
21 Correct 67 ms 10096 KB Output is correct
22 Correct 386 ms 64464 KB Output is correct