답안 #808765

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
808765 2023-08-05T10:46:28 Z tlnk07 Janjetina (COCI21_janjetina) C++17
15 / 110
8 ms 612 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 7 ms 340 KB Output is correct
5 Correct 7 ms 448 KB Output is correct
6 Correct 7 ms 468 KB Output is correct
7 Correct 7 ms 448 KB Output is correct
8 Correct 7 ms 352 KB Output is correct
9 Correct 6 ms 340 KB Output is correct
10 Correct 5 ms 392 KB Output is correct
11 Correct 6 ms 396 KB Output is correct
12 Correct 8 ms 340 KB Output is correct
13 Correct 6 ms 340 KB Output is correct
14 Correct 6 ms 352 KB Output is correct
15 Correct 6 ms 340 KB Output is correct
16 Correct 6 ms 340 KB Output is correct
17 Correct 6 ms 352 KB Output is correct
18 Correct 6 ms 356 KB Output is correct
19 Correct 6 ms 340 KB Output is correct
20 Correct 6 ms 340 KB Output is correct
21 Correct 6 ms 388 KB Output is correct
22 Correct 6 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 8 ms 436 KB Output is correct
5 Runtime error 1 ms 612 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 7 ms 340 KB Output is correct
5 Correct 7 ms 448 KB Output is correct
6 Correct 7 ms 468 KB Output is correct
7 Correct 7 ms 448 KB Output is correct
8 Correct 7 ms 352 KB Output is correct
9 Correct 6 ms 340 KB Output is correct
10 Correct 5 ms 392 KB Output is correct
11 Correct 6 ms 396 KB Output is correct
12 Correct 8 ms 340 KB Output is correct
13 Correct 6 ms 340 KB Output is correct
14 Correct 6 ms 352 KB Output is correct
15 Correct 6 ms 340 KB Output is correct
16 Correct 6 ms 340 KB Output is correct
17 Correct 6 ms 352 KB Output is correct
18 Correct 6 ms 356 KB Output is correct
19 Correct 6 ms 340 KB Output is correct
20 Correct 6 ms 340 KB Output is correct
21 Correct 6 ms 388 KB Output is correct
22 Correct 6 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 8 ms 436 KB Output is correct
27 Runtime error 1 ms 612 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -