Submission #808767

# Submission time Handle Problem Language Result Execution time Memory
808767 2023-08-05T10:46:57 Z tlnk07 Janjetina (COCI21_janjetina) C++17
15 / 110
1500 ms 8148 KB
#include<bits/stdc++.h>
using namespace std;

long long n, k, cnt = 0, sum, height;
vector<pair<int, int>> vec[100001];
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 time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 7 ms 2644 KB Output is correct
5 Correct 7 ms 2760 KB Output is correct
6 Correct 8 ms 2644 KB Output is correct
7 Correct 8 ms 2764 KB Output is correct
8 Correct 7 ms 2760 KB Output is correct
9 Correct 6 ms 2644 KB Output is correct
10 Correct 7 ms 2712 KB Output is correct
11 Correct 6 ms 2716 KB Output is correct
12 Correct 9 ms 2704 KB Output is correct
13 Correct 7 ms 2644 KB Output is correct
14 Correct 7 ms 2644 KB Output is correct
15 Correct 7 ms 2704 KB Output is correct
16 Correct 7 ms 2712 KB Output is correct
17 Correct 7 ms 2644 KB Output is correct
18 Correct 9 ms 2684 KB Output is correct
19 Correct 7 ms 2644 KB Output is correct
20 Correct 7 ms 2644 KB Output is correct
21 Correct 8 ms 2644 KB Output is correct
22 Correct 7 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2608 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 8 ms 2760 KB Output is correct
5 Correct 646 ms 3616 KB Output is correct
6 Execution timed out 1559 ms 8148 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 7 ms 2644 KB Output is correct
5 Correct 7 ms 2760 KB Output is correct
6 Correct 8 ms 2644 KB Output is correct
7 Correct 8 ms 2764 KB Output is correct
8 Correct 7 ms 2760 KB Output is correct
9 Correct 6 ms 2644 KB Output is correct
10 Correct 7 ms 2712 KB Output is correct
11 Correct 6 ms 2716 KB Output is correct
12 Correct 9 ms 2704 KB Output is correct
13 Correct 7 ms 2644 KB Output is correct
14 Correct 7 ms 2644 KB Output is correct
15 Correct 7 ms 2704 KB Output is correct
16 Correct 7 ms 2712 KB Output is correct
17 Correct 7 ms 2644 KB Output is correct
18 Correct 9 ms 2684 KB Output is correct
19 Correct 7 ms 2644 KB Output is correct
20 Correct 7 ms 2644 KB Output is correct
21 Correct 8 ms 2644 KB Output is correct
22 Correct 7 ms 2644 KB Output is correct
23 Correct 1 ms 2644 KB Output is correct
24 Correct 1 ms 2608 KB Output is correct
25 Correct 1 ms 2644 KB Output is correct
26 Correct 8 ms 2760 KB Output is correct
27 Correct 646 ms 3616 KB Output is correct
28 Execution timed out 1559 ms 8148 KB Time limit exceeded
29 Halted 0 ms 0 KB -