Submission #1099084

# Submission time Handle Problem Language Result Execution time Memory
1099084 2024-10-10T13:31:21 Z vjudge1 Janjetina (COCI21_janjetina) C++17
15 / 110
11 ms 608 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "memory.h"
#define bitcount __builtin_popcountll
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<long long,null_type,less_equal<>,rb_tree_tag,tree_order_statistics_node_update>;

vector<pair<int,int>> adj[1000];
int mx[1000], dep[1000];

void dfs(int u, int p = -1) {
    for (auto [v, w] : adj[u]) if (v != p) {
        dep[v] = dep[u] + 1;
        mx[v] = max(mx[u], w);
        dfs(v, u);
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int n,k; cin >> n >> k;
    for (int i = 0; i < n-1; i++) {
        int u,v,w; cin >> u >> v >> w;
        u--, v--;
        adj[u].emplace_back(v, w);
        adj[v].emplace_back(u, w);
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        dep[i] = mx[i] = 0;
        dfs(i);
        for (int j = 0; j < n; j++) if (mx[j] - dep[j] >= k) {
            ans++;
        }
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 8 ms 604 KB Output is correct
5 Correct 8 ms 600 KB Output is correct
6 Correct 8 ms 488 KB Output is correct
7 Correct 8 ms 604 KB Output is correct
8 Correct 8 ms 600 KB Output is correct
9 Correct 6 ms 488 KB Output is correct
10 Correct 6 ms 344 KB Output is correct
11 Correct 6 ms 344 KB Output is correct
12 Correct 8 ms 532 KB Output is correct
13 Correct 8 ms 348 KB Output is correct
14 Correct 7 ms 536 KB Output is correct
15 Correct 7 ms 348 KB Output is correct
16 Correct 11 ms 344 KB Output is correct
17 Correct 9 ms 532 KB Output is correct
18 Correct 10 ms 348 KB Output is correct
19 Correct 7 ms 348 KB Output is correct
20 Correct 7 ms 348 KB Output is correct
21 Correct 8 ms 348 KB Output is correct
22 Correct 7 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 8 ms 608 KB Output is correct
5 Runtime error 1 ms 604 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 8 ms 604 KB Output is correct
5 Correct 8 ms 600 KB Output is correct
6 Correct 8 ms 488 KB Output is correct
7 Correct 8 ms 604 KB Output is correct
8 Correct 8 ms 600 KB Output is correct
9 Correct 6 ms 488 KB Output is correct
10 Correct 6 ms 344 KB Output is correct
11 Correct 6 ms 344 KB Output is correct
12 Correct 8 ms 532 KB Output is correct
13 Correct 8 ms 348 KB Output is correct
14 Correct 7 ms 536 KB Output is correct
15 Correct 7 ms 348 KB Output is correct
16 Correct 11 ms 344 KB Output is correct
17 Correct 9 ms 532 KB Output is correct
18 Correct 10 ms 348 KB Output is correct
19 Correct 7 ms 348 KB Output is correct
20 Correct 7 ms 348 KB Output is correct
21 Correct 8 ms 348 KB Output is correct
22 Correct 7 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 8 ms 608 KB Output is correct
27 Runtime error 1 ms 604 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -