Submission #863205

# Submission time Handle Problem Language Result Execution time Memory
863205 2023-10-19T18:16:01 Z Irate Janjetina (COCI21_janjetina) C++14
15 / 110
16 ms 24156 KB
#include<bits/stdc++.h>
using namespace std;
const int mxN = 1e3 + 3;
vector<pair<int, int>> G[mxN];
int depth[mxN][mxN], path_mx[mxN][mxN];
void dfs(int node, int par, int root){
    for(pair<int, int> &v : G[node]){
        if(v.first != par){
            depth[root][v.first] = depth[root][node] + 1;
            path_mx[root][v.first] = max(path_mx[root][node], v.second);
            dfs(v.first, node, root);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for(int i = 1;i < n;++i){
        int u, v, w;
        cin >> u >> v >> w;
        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }
    for(int i = 1;i <= n;++i){
        dfs(i, i, i);
    }
    long long res = 0;
    for(int i = 1;i <= n;++i){
        for(int j = 1;j <= n;++j){
            if(i != j && path_mx[i][j] - depth[i][j] >= k){
                res++;
            }
        }
    }
    cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 11 ms 8284 KB Output is correct
5 Correct 11 ms 8404 KB Output is correct
6 Correct 11 ms 8436 KB Output is correct
7 Correct 11 ms 8284 KB Output is correct
8 Correct 11 ms 8280 KB Output is correct
9 Correct 10 ms 8280 KB Output is correct
10 Correct 13 ms 8284 KB Output is correct
11 Correct 10 ms 8284 KB Output is correct
12 Correct 12 ms 8280 KB Output is correct
13 Correct 11 ms 8284 KB Output is correct
14 Correct 11 ms 8180 KB Output is correct
15 Correct 12 ms 8284 KB Output is correct
16 Correct 11 ms 8280 KB Output is correct
17 Correct 11 ms 8284 KB Output is correct
18 Correct 11 ms 8284 KB Output is correct
19 Correct 15 ms 8164 KB Output is correct
20 Correct 15 ms 8276 KB Output is correct
21 Correct 16 ms 8176 KB Output is correct
22 Correct 11 ms 8264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 11 ms 8428 KB Output is correct
5 Runtime error 13 ms 24156 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 11 ms 8284 KB Output is correct
5 Correct 11 ms 8404 KB Output is correct
6 Correct 11 ms 8436 KB Output is correct
7 Correct 11 ms 8284 KB Output is correct
8 Correct 11 ms 8280 KB Output is correct
9 Correct 10 ms 8280 KB Output is correct
10 Correct 13 ms 8284 KB Output is correct
11 Correct 10 ms 8284 KB Output is correct
12 Correct 12 ms 8280 KB Output is correct
13 Correct 11 ms 8284 KB Output is correct
14 Correct 11 ms 8180 KB Output is correct
15 Correct 12 ms 8284 KB Output is correct
16 Correct 11 ms 8280 KB Output is correct
17 Correct 11 ms 8284 KB Output is correct
18 Correct 11 ms 8284 KB Output is correct
19 Correct 15 ms 8164 KB Output is correct
20 Correct 15 ms 8276 KB Output is correct
21 Correct 16 ms 8176 KB Output is correct
22 Correct 11 ms 8264 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 11 ms 8428 KB Output is correct
27 Runtime error 13 ms 24156 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -