Submission #104501

# Submission time Handle Problem Language Result Execution time Memory
104501 2019-04-07T08:39:28 Z dfistric Crocodile's Underground City (IOI11_crocodile) C++14
89 / 100
2000 ms 80180 KB
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
#define X first
#define Y second

using namespace std;

const int MAXN = 100100;
ll dist[MAXN];
ll inf = (1LL << 60);
vector <pair <int, ll> > ve[MAXN];
int n, m;

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

    REP(i, m) {
        int a = R[i][0], b = R[i][1];
        ll c = L[i];
        ve[a].push_back({b, c});
        ve[b].push_back({a, c});
    }

    REP(i, n) dist[i] = inf;
    REP(i, K) dist[P[i]] = 0;

    REP(t, n) {
        REP(x, n) {
            ll a = inf, b = inf;
            int num = 0;
            for (auto tr : ve[x]) {
                int y = tr.X;
                ll d = tr.Y;
                if (dist[y] != inf) num++;
                b = min(b, dist[y] + d);
                if (a > b) swap(a, b); 
            }
            
            if (dist[x] > b) {
                dist[x] = b;
            }
        }
    }

    return dist[0];
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 5 ms 2688 KB Output is correct
3 Correct 5 ms 2688 KB Output is correct
4 Correct 9 ms 2816 KB Output is correct
5 Correct 9 ms 2816 KB Output is correct
6 Correct 7 ms 2688 KB Output is correct
7 Correct 10 ms 2816 KB Output is correct
8 Correct 10 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 5 ms 2688 KB Output is correct
3 Correct 5 ms 2688 KB Output is correct
4 Correct 9 ms 2816 KB Output is correct
5 Correct 9 ms 2816 KB Output is correct
6 Correct 7 ms 2688 KB Output is correct
7 Correct 10 ms 2816 KB Output is correct
8 Correct 10 ms 2816 KB Output is correct
9 Correct 11 ms 3072 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 7 ms 2860 KB Output is correct
12 Correct 19 ms 3340 KB Output is correct
13 Correct 14 ms 3584 KB Output is correct
14 Correct 5 ms 2816 KB Output is correct
15 Correct 7 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 5 ms 2688 KB Output is correct
3 Correct 5 ms 2688 KB Output is correct
4 Correct 9 ms 2816 KB Output is correct
5 Correct 9 ms 2816 KB Output is correct
6 Correct 7 ms 2688 KB Output is correct
7 Correct 10 ms 2816 KB Output is correct
8 Correct 10 ms 2816 KB Output is correct
9 Correct 11 ms 3072 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 7 ms 2860 KB Output is correct
12 Correct 19 ms 3340 KB Output is correct
13 Correct 14 ms 3584 KB Output is correct
14 Correct 5 ms 2816 KB Output is correct
15 Correct 7 ms 2816 KB Output is correct
16 Execution timed out 2036 ms 80180 KB Time limit exceeded
17 Halted 0 ms 0 KB -