Submission #808760

#TimeUsernameProblemLanguageResultExecution timeMemory
808760tlnk07Janjetina (COCI21_janjetina)C++17
0 / 110
1573 ms428 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 y, int p, int len, int h) { if(x == y) { sum = len; height = h; check = true; return; } for(pair<int, int> c : vec[x]) { if(c.first != p) dfs(c.first, y, x, max(len, c.second), h + 1); if(check) return; } } int main() { 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) { for(int j = i + 1; j <= n; ++j) { check = height = sum = 0; dfs(i, j, 0, 0, 0); if(sum - height >= k) { ++cnt; } } } cout << cnt * 2; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:38:19: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   38 |    check = height = sum = 0;
      |            ~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...