Submission #1000843

# Submission time Handle Problem Language Result Execution time Memory
1000843 2024-06-18T10:03:05 Z Tsog Race (IOI11_race) C++14
9 / 100
122 ms 262144 KB
#include "race.h"
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;


const int INF = INT_MAX;

void dfs(int v, int parent, vector<vector<int>>& dp, const vector<vector<pair<int,int>>>& adj) {
	for (auto i = 0u; i < adj[v].size(); ++i) {
        int u = adj[v][i].first;
        int cos = adj[v][i].second;
        
        if (u == parent) {
            continue;
        }
        
        for (int k = cos; k <= 100; ++k) { 
            if (dp[v][k - cos] != INF) {
                dp[u][k] = min(dp[u][k], dp[v][k - cos] + 1);
            }
        }
        
        dfs(u, v, dp, adj);
    }
}


int best_path(int N, int K, int H[][2], int L[]) {
    vector<vector<pair<int,int>>> adj(N);
    for (int i = 0; i < N - 1; ++i) {
        int u = H[i][0], v = H[i][1];
        adj[u].push_back(mp(v,L[i]));
        adj[v].push_back(mp(u,L[i]));
    }
    
    vector<vector<int>> dp(N, vector<int>(200001, INF));
    for(int i = 0 ; i < N ; i ++){
    	dp[i][0] = 0;
    }
    
    dfs(0, -1, dp, adj);
    
    int result = INF;
    for (int v = 0; v < N; ++v) {
        result = min(result, dp[v][K]);
    }
    
    return (result == INF ? -1 : result);
}
# Verdict Execution time Memory Grader output
1 Correct 31 ms 81804 KB Output is correct
2 Correct 32 ms 81744 KB Output is correct
3 Correct 31 ms 81744 KB Output is correct
4 Correct 33 ms 81744 KB Output is correct
5 Correct 33 ms 81748 KB Output is correct
6 Correct 30 ms 81744 KB Output is correct
7 Correct 31 ms 81748 KB Output is correct
8 Correct 32 ms 81748 KB Output is correct
9 Correct 32 ms 81708 KB Output is correct
10 Correct 32 ms 81748 KB Output is correct
11 Correct 32 ms 81748 KB Output is correct
12 Correct 35 ms 82004 KB Output is correct
13 Correct 33 ms 81752 KB Output is correct
14 Correct 32 ms 81752 KB Output is correct
15 Correct 31 ms 81700 KB Output is correct
16 Correct 39 ms 81744 KB Output is correct
17 Correct 32 ms 81764 KB Output is correct
18 Correct 35 ms 81640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 81804 KB Output is correct
2 Correct 32 ms 81744 KB Output is correct
3 Correct 31 ms 81744 KB Output is correct
4 Correct 33 ms 81744 KB Output is correct
5 Correct 33 ms 81748 KB Output is correct
6 Correct 30 ms 81744 KB Output is correct
7 Correct 31 ms 81748 KB Output is correct
8 Correct 32 ms 81748 KB Output is correct
9 Correct 32 ms 81708 KB Output is correct
10 Correct 32 ms 81748 KB Output is correct
11 Correct 32 ms 81748 KB Output is correct
12 Correct 35 ms 82004 KB Output is correct
13 Correct 33 ms 81752 KB Output is correct
14 Correct 32 ms 81752 KB Output is correct
15 Correct 31 ms 81700 KB Output is correct
16 Correct 39 ms 81744 KB Output is correct
17 Correct 32 ms 81764 KB Output is correct
18 Correct 35 ms 81640 KB Output is correct
19 Incorrect 5 ms 11100 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 81804 KB Output is correct
2 Correct 32 ms 81744 KB Output is correct
3 Correct 31 ms 81744 KB Output is correct
4 Correct 33 ms 81744 KB Output is correct
5 Correct 33 ms 81748 KB Output is correct
6 Correct 30 ms 81744 KB Output is correct
7 Correct 31 ms 81748 KB Output is correct
8 Correct 32 ms 81748 KB Output is correct
9 Correct 32 ms 81708 KB Output is correct
10 Correct 32 ms 81748 KB Output is correct
11 Correct 32 ms 81748 KB Output is correct
12 Correct 35 ms 82004 KB Output is correct
13 Correct 33 ms 81752 KB Output is correct
14 Correct 32 ms 81752 KB Output is correct
15 Correct 31 ms 81700 KB Output is correct
16 Correct 39 ms 81744 KB Output is correct
17 Correct 32 ms 81764 KB Output is correct
18 Correct 35 ms 81640 KB Output is correct
19 Runtime error 122 ms 262144 KB Execution killed with signal 9
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 81804 KB Output is correct
2 Correct 32 ms 81744 KB Output is correct
3 Correct 31 ms 81744 KB Output is correct
4 Correct 33 ms 81744 KB Output is correct
5 Correct 33 ms 81748 KB Output is correct
6 Correct 30 ms 81744 KB Output is correct
7 Correct 31 ms 81748 KB Output is correct
8 Correct 32 ms 81748 KB Output is correct
9 Correct 32 ms 81708 KB Output is correct
10 Correct 32 ms 81748 KB Output is correct
11 Correct 32 ms 81748 KB Output is correct
12 Correct 35 ms 82004 KB Output is correct
13 Correct 33 ms 81752 KB Output is correct
14 Correct 32 ms 81752 KB Output is correct
15 Correct 31 ms 81700 KB Output is correct
16 Correct 39 ms 81744 KB Output is correct
17 Correct 32 ms 81764 KB Output is correct
18 Correct 35 ms 81640 KB Output is correct
19 Incorrect 5 ms 11100 KB Output isn't correct
20 Halted 0 ms 0 KB -