Submission #115149

# Submission time Handle Problem Language Result Execution time Memory
115149 2019-06-05T12:31:46 Z songc Crocodile's Underground City (IOI11_crocodile) C++14
89 / 100
2000 ms 80688 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, LL> pii;

int N, M;
vector<pii> G[101010];
LL F[101010], S[101010];
bool chk[101010];

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[])
{
    N=n, M=m;
    for (int i=0; i<M; i++){
        G[r[i][0]].push_back(pii(r[i][1], l[i]));
        G[r[i][1]].push_back(pii(r[i][0], l[i]));
    }
    for (int i=0; i<k; i++) {
        chk[p[i]] = true;
        for (pii v : G[p[i]]){
            if (!F[v.first] || F[v.first] > v.second) S[v.first] = F[v.first], F[v.first] = v.second;
            else if (!S[v.first] || S[v.first] > v.second) S[v.first] = v.second;
        }
    }
    while(1){
        LL Min=1234567890123456;
        int u=-1;
        for (int j=0; j<N; j++) if (!chk[j] && S[j] && Min > S[j]) Min = S[j], u = j;
        if (u==-1) break;
        chk[u] = true;
        for (pii v : G[u]){
            if (!F[v.first] || F[v.first] > v.second+S[u]) S[v.first] = F[v.first], F[v.first] = v.second+S[u];
            else if (!S[v.first] || S[v.first] > v.second+S[u]) S[v.first] = v.second+S[u];
        }
    }
    return S[0];
}


# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 6 ms 2816 KB Output is correct
5 Correct 5 ms 2816 KB Output is correct
6 Correct 4 ms 2816 KB Output is correct
7 Correct 5 ms 2816 KB Output is correct
8 Correct 5 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 6 ms 2816 KB Output is correct
5 Correct 5 ms 2816 KB Output is correct
6 Correct 4 ms 2816 KB Output is correct
7 Correct 5 ms 2816 KB Output is correct
8 Correct 5 ms 2816 KB Output is correct
9 Correct 6 ms 3200 KB Output is correct
10 Correct 4 ms 2816 KB Output is correct
11 Correct 6 ms 2944 KB Output is correct
12 Correct 8 ms 3456 KB Output is correct
13 Correct 7 ms 3584 KB Output is correct
14 Correct 5 ms 2752 KB Output is correct
15 Correct 5 ms 2944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
4 Correct 6 ms 2816 KB Output is correct
5 Correct 5 ms 2816 KB Output is correct
6 Correct 4 ms 2816 KB Output is correct
7 Correct 5 ms 2816 KB Output is correct
8 Correct 5 ms 2816 KB Output is correct
9 Correct 6 ms 3200 KB Output is correct
10 Correct 4 ms 2816 KB Output is correct
11 Correct 6 ms 2944 KB Output is correct
12 Correct 8 ms 3456 KB Output is correct
13 Correct 7 ms 3584 KB Output is correct
14 Correct 5 ms 2752 KB Output is correct
15 Correct 5 ms 2944 KB Output is correct
16 Execution timed out 2051 ms 80688 KB Time limit exceeded
17 Halted 0 ms 0 KB -