Submission #113059

# Submission time Handle Problem Language Result Execution time Memory
113059 2019-05-23T13:16:22 Z oolimry Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
1339 ms 75024 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);
    }

    set<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++){
                       ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 4 ms 640 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 5 ms 1024 KB Output is correct
13 Correct 5 ms 1152 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 4 ms 640 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 5 ms 1024 KB Output is correct
13 Correct 5 ms 1152 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 512 KB Output is correct
16 Correct 765 ms 65516 KB Output is correct
17 Correct 150 ms 20728 KB Output is correct
18 Correct 234 ms 23032 KB Output is correct
19 Correct 1339 ms 75024 KB Output is correct
20 Correct 349 ms 52628 KB Output is correct
21 Correct 70 ms 8696 KB Output is correct
22 Correct 396 ms 50260 KB Output is correct