Submission #381919

# Submission time Handle Problem Language Result Execution time Memory
381919 2021-03-26T07:07:05 Z VEGAnn Janjetina (COCI21_janjetina) C++14
0 / 110
2 ms 620 KB
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define PB push_back
#define i2 array<int,2>
using namespace std;
typedef long long ll;
const int MX = int(1e7) + 10;
const int oo = 2e9;
const int N = 2010;
vector<i2> g[N];
int n, k, ans;

void dfs(int v, int p, int mx, int len){
    if (mx - len >= k)
        ans++;

    for (i2 u : g[v]){
        if (u[0] == p) continue;

        dfs(u[0], v, max(mx, u[1]), len + 1);
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    cin >> n >> k;

    assert(n <= 100);

    for (int i = 1; i < n; i++){
        int x, y, w; cin >> x >> y >> w;

        x--; y--;

        g[x].PB({y, w});
        g[y].PB({x, w});
    }

    for (int i = 0; i < n; i++)
        dfs(i, -1, 0, 0);

    cout << ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Runtime error 2 ms 620 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Runtime error 1 ms 620 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Runtime error 2 ms 620 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -