Submission #963242

# Submission time Handle Problem Language Result Execution time Memory
963242 2024-04-14T19:13:39 Z SuPythony Crocodile's Underground City (IOI11_crocodile) C++17
46 / 100
2 ms 4696 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

vector<vector<pair<int,int>>> al(1000, vector<pair<int,int>>());
vector<int> is_exit(1000, 0);
vector<int> dp(1000,0);
vector<int> vis(1000,0);

void dfs(int u) {
    if (is_exit[u]) return;
    vis[u]=1;
    int mn=INT_MAX;
    int mn2=INT_MAX;
    for (auto v: al[u]) {
        if (vis[v.first]) continue;
        dfs(v.first);
        if (dp[v.first]+v.second<=mn) {
            mn2=mn;
            mn=min(mn,dp[v.first]+v.second);
        } else {
            mn2=min(mn2,dp[v.first]+v.second);
        }
    }
    dp[u]=mn2;
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    for (int i=0; i<M; i++) {
        int u=R[i][0], v=R[i][1];
        al[u].push_back({v, L[i]});
        al[v].push_back({u, L[i]});
    }
    for (int i=0; i<K; i++) {
        is_exit[P[i]]=1;
    }
    if (is_exit[0]) return 0;
    dfs(0);
    return dp[0];
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4576 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4576 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Incorrect 2 ms 4696 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4576 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Incorrect 2 ms 4696 KB Output isn't correct
10 Halted 0 ms 0 KB -