Submission #381973

# Submission time Handle Problem Language Result Execution time Memory
381973 2021-03-26T08:17:05 Z Slavita Janjetina (COCI21_janjetina) C++14
15 / 110
1500 ms 6636 KB
#include <bits/stdc++.h>
#define ve vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define si(v) (int)v.size()
#define en '\n'
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

const int N = 1e5 + 228;
const int big = 1e9;
int n, k, ans;
bool mrk[N];
vector<pi> g[N];

void dfs(int v, int st, int mxn){
    if (st != 0 && mxn - st >= k){
        ans++;
    }
    mrk[v] = 1;
    for (int i = 0; i < si(g[v]); i++){
        int u = g[v][i].fi;
        if (mrk[u]) continue;
        dfs(u, st + 1, max(mxn, g[v][i].se));
    }
}

int main(){
    iostream::sync_with_stdio(false); cin.tie(0); ios_base::sync_with_stdio(false); cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n >> k;
    for (int i = 1; i <= n - 1; i++){
        int a, b, x;
        cin >> a >> b >> x;
        g[a].pb(mp(b, x));
        g[b].pb(mp(a, x));
    }

    ans = 0;
    for (int i = 1; i <= n; i++){
        //if (i == j) continue;
        for (int i = 1; i <= n; i++) mrk[i] = 0;
        dfs(i, 0, 0);
        //cout << i << '|' << j << '|' << dans << "|k=" << k << en;
    }
    cout << ans;
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 13 ms 2796 KB Output is correct
5 Correct 13 ms 2796 KB Output is correct
6 Correct 16 ms 2796 KB Output is correct
7 Correct 13 ms 2796 KB Output is correct
8 Correct 16 ms 2796 KB Output is correct
9 Correct 16 ms 2668 KB Output is correct
10 Correct 17 ms 2668 KB Output is correct
11 Correct 16 ms 2668 KB Output is correct
12 Correct 18 ms 2668 KB Output is correct
13 Correct 21 ms 2668 KB Output is correct
14 Correct 21 ms 2668 KB Output is correct
15 Correct 19 ms 2668 KB Output is correct
16 Correct 22 ms 2668 KB Output is correct
17 Correct 19 ms 2668 KB Output is correct
18 Correct 26 ms 2668 KB Output is correct
19 Correct 21 ms 2668 KB Output is correct
20 Correct 18 ms 2668 KB Output is correct
21 Correct 22 ms 2668 KB Output is correct
22 Correct 22 ms 2796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 3 ms 2668 KB Output is correct
4 Correct 14 ms 2796 KB Output is correct
5 Correct 1031 ms 3436 KB Output is correct
6 Execution timed out 1576 ms 6636 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 13 ms 2796 KB Output is correct
5 Correct 13 ms 2796 KB Output is correct
6 Correct 16 ms 2796 KB Output is correct
7 Correct 13 ms 2796 KB Output is correct
8 Correct 16 ms 2796 KB Output is correct
9 Correct 16 ms 2668 KB Output is correct
10 Correct 17 ms 2668 KB Output is correct
11 Correct 16 ms 2668 KB Output is correct
12 Correct 18 ms 2668 KB Output is correct
13 Correct 21 ms 2668 KB Output is correct
14 Correct 21 ms 2668 KB Output is correct
15 Correct 19 ms 2668 KB Output is correct
16 Correct 22 ms 2668 KB Output is correct
17 Correct 19 ms 2668 KB Output is correct
18 Correct 26 ms 2668 KB Output is correct
19 Correct 21 ms 2668 KB Output is correct
20 Correct 18 ms 2668 KB Output is correct
21 Correct 22 ms 2668 KB Output is correct
22 Correct 22 ms 2796 KB Output is correct
23 Correct 2 ms 2668 KB Output is correct
24 Correct 2 ms 2668 KB Output is correct
25 Correct 3 ms 2668 KB Output is correct
26 Correct 14 ms 2796 KB Output is correct
27 Correct 1031 ms 3436 KB Output is correct
28 Execution timed out 1576 ms 6636 KB Time limit exceeded
29 Halted 0 ms 0 KB -