Submission #808765

#TimeUsernameProblemLanguageResultExecution timeMemory
808765tlnk07Janjetina (COCI21_janjetina)C++17
15 / 110
8 ms612 KiB
#include<bits/stdc++.h> using namespace std; long long n, k, cnt = 0, sum, height; vector<pair<int, int>> vec[1001]; bool check = 0; void dfs(int x, int p, int len, int h) { if(len - h >= k) ++cnt; for(pair<int, int> c : vec[x]) if(c.first != p) dfs(c.first, x, max(len, c.second), h + 1); } int main() { ios::sync_with_stdio (false); cin.tie (0); cout.tie (0); cin >> n >> k; for(int i = 1; i < n; ++i) { long long x, y, z; cin >> x >> y >> z; vec[x].push_back({y, z}); vec[y].push_back({x, z}); } for(int i = 1; i <= n; ++i) { dfs(i, 0, 0, 0); } cout << cnt; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...