Submission #64085

# Submission time Handle Problem Language Result Execution time Memory
64085 2018-08-03T10:33:03 Z zubec Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
1597 ms 105308 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

const int N = 100100;

vector <pair<int, int> > g[N];

int n, pr[N];

long long d[N][2];

map<int, int> blockd[N];


int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    n = N;
    for (int i = 0; i < M; i++){
        int u = R[i][0]+1, v = R[i][1]+1;
        g[u].push_back({v, L[i]});
        g[v].push_back({u, L[i]});
    }
    set<pair<long long, int> > q;
    for (int i = 1; i <= n; i++)
        d[i][0] = d[i][1] = 1e15;
    for (int i = 0; i < K; i++){
        int v = P[i]+1;
        d[v][1] = 0;
        d[v][0] = 0;
        q.insert({0, v});
    }
    while(!q.empty()){
        int v = q.begin()->second;
        //cout << v-1 << ' ' << d2[v] << endl;
        q.erase(q.begin());
        for (int i = 0; i < g[v].size(); i++){
            int to = g[v][i].first, len = g[v][i].second;
            if (d[v][1] + len < d[to][0]){
                q.erase({d[to][1], to});
                d[to][1] = d[to][0];
                d[to][0] = d[v][1] + len;
                q.insert({d[to][1], to});
            } else
            if (d[v][1] + len < d[to][1]){
                q.erase({d[to][1], to});
                d[to][1] = d[v][1] + len;
                q.insert({d[to][1], to});
            }
        }
    }
    long long mn = d[1][1];
    if (mn == 1e15)
        mn = -1;
    return mn;

}

/**

13 12 9
0 2 4
0 1 1
0 3 11
2 8 13
2 9 23
2 7 3
1 5 7
1 6 15
1 4 11
3 10 3
3 11 1
3 12 2
8 9 7 5 6 12 11 10 4
13

*/

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:36:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < g[v].size(); i++){
                         ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 11 ms 7416 KB Output is correct
2 Correct 12 ms 7524 KB Output is correct
3 Correct 10 ms 7752 KB Output is correct
4 Correct 13 ms 7752 KB Output is correct
5 Correct 11 ms 7768 KB Output is correct
6 Correct 12 ms 7788 KB Output is correct
7 Correct 11 ms 7868 KB Output is correct
8 Correct 11 ms 7900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 7416 KB Output is correct
2 Correct 12 ms 7524 KB Output is correct
3 Correct 10 ms 7752 KB Output is correct
4 Correct 13 ms 7752 KB Output is correct
5 Correct 11 ms 7768 KB Output is correct
6 Correct 12 ms 7788 KB Output is correct
7 Correct 11 ms 7868 KB Output is correct
8 Correct 11 ms 7900 KB Output is correct
9 Correct 15 ms 8044 KB Output is correct
10 Correct 8 ms 8044 KB Output is correct
11 Correct 14 ms 8044 KB Output is correct
12 Correct 17 ms 8328 KB Output is correct
13 Correct 13 ms 8572 KB Output is correct
14 Correct 8 ms 8572 KB Output is correct
15 Correct 12 ms 8572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 7416 KB Output is correct
2 Correct 12 ms 7524 KB Output is correct
3 Correct 10 ms 7752 KB Output is correct
4 Correct 13 ms 7752 KB Output is correct
5 Correct 11 ms 7768 KB Output is correct
6 Correct 12 ms 7788 KB Output is correct
7 Correct 11 ms 7868 KB Output is correct
8 Correct 11 ms 7900 KB Output is correct
9 Correct 15 ms 8044 KB Output is correct
10 Correct 8 ms 8044 KB Output is correct
11 Correct 14 ms 8044 KB Output is correct
12 Correct 17 ms 8328 KB Output is correct
13 Correct 13 ms 8572 KB Output is correct
14 Correct 8 ms 8572 KB Output is correct
15 Correct 12 ms 8572 KB Output is correct
16 Correct 1061 ms 61944 KB Output is correct
17 Correct 137 ms 61944 KB Output is correct
18 Correct 225 ms 61944 KB Output is correct
19 Correct 1597 ms 90760 KB Output is correct
20 Correct 460 ms 94512 KB Output is correct
21 Correct 105 ms 94512 KB Output is correct
22 Correct 510 ms 105308 KB Output is correct