Submission #425833

# Submission time Handle Problem Language Result Execution time Memory
425833 2021-06-13T11:48:02 Z dxz05 Crocodile's Underground City (IOI11_crocodile) C++14
89 / 100
2000 ms 44680 KB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define MP make_pair

const ll INF = 1e18 + 1e8;
const int N = 3e5 + 3e2;

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

ll dp[N];
bool processed[N];
int cnt[N];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    for (int i = 0; i < M; i++){
        g[R[i][0]].emplace_back(R[i][1], L[i]);
        g[R[i][1]].emplace_back(R[i][0], L[i]);
    }

    fill(dp, dp + N, INF);

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

    for (int it = 0; it < N; it++){
        for (int i = 0; i < N; i++){
            vector<ll> vec;
            for (auto edge : g[i]){
                int j = edge.first, w = edge.second;
                if (dp[j] != INF) vec.push_back(dp[j] + w);
            }

            if (vec.size() < 2) continue;
            sort(vec.begin(), vec.end());
            dp[i] = min(dp[i], vec[1]);
    //        cout << i << ' ' << dp[i] << endl;
        }
    }

    //for (int i = 0; i < N; i++) cout << dp[i] << ' ';

    return dp[0];
}

/**
5 7 2
0 2 4
0 3 3
3 2 2
2 1 10
0 1 100
0 4 7
3 4 9
1 3
14
*/
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7372 KB Output is correct
2 Correct 5 ms 7372 KB Output is correct
3 Correct 13 ms 7372 KB Output is correct
4 Correct 82 ms 7372 KB Output is correct
5 Correct 75 ms 7372 KB Output is correct
6 Correct 41 ms 7372 KB Output is correct
7 Correct 90 ms 7420 KB Output is correct
8 Correct 84 ms 7372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7372 KB Output is correct
2 Correct 5 ms 7372 KB Output is correct
3 Correct 13 ms 7372 KB Output is correct
4 Correct 82 ms 7372 KB Output is correct
5 Correct 75 ms 7372 KB Output is correct
6 Correct 41 ms 7372 KB Output is correct
7 Correct 90 ms 7420 KB Output is correct
8 Correct 84 ms 7372 KB Output is correct
9 Correct 69 ms 7584 KB Output is correct
10 Correct 9 ms 7372 KB Output is correct
11 Correct 46 ms 7372 KB Output is correct
12 Correct 159 ms 7756 KB Output is correct
13 Correct 108 ms 7804 KB Output is correct
14 Correct 16 ms 7372 KB Output is correct
15 Correct 41 ms 7372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7372 KB Output is correct
2 Correct 5 ms 7372 KB Output is correct
3 Correct 13 ms 7372 KB Output is correct
4 Correct 82 ms 7372 KB Output is correct
5 Correct 75 ms 7372 KB Output is correct
6 Correct 41 ms 7372 KB Output is correct
7 Correct 90 ms 7420 KB Output is correct
8 Correct 84 ms 7372 KB Output is correct
9 Correct 69 ms 7584 KB Output is correct
10 Correct 9 ms 7372 KB Output is correct
11 Correct 46 ms 7372 KB Output is correct
12 Correct 159 ms 7756 KB Output is correct
13 Correct 108 ms 7804 KB Output is correct
14 Correct 16 ms 7372 KB Output is correct
15 Correct 41 ms 7372 KB Output is correct
16 Execution timed out 2059 ms 44680 KB Time limit exceeded
17 Halted 0 ms 0 KB -