52382023-04-23 16:36:44szilEnergiatakarékos ellenőrzéscpp14Wrong answer 0/10061ms43928 KiB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 100001;

vector<int> g[MAXN];

int ans = 0;

int dfs(int x, int p = -1){
	int r = 1;
	for(int i : g[x]){
		if(i==p)continue;
		r += dfs(i, x);
	}
	if (g[x].size() != 1 || x == 1) ans += min(8, r*2);
	return r;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1);
	cout<<ans<<"\n";
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted4ms6668 KiB
2Wrong answer46ms14448 KiB
subtask20/5
3Wrong answer32ms15968 KiB
4Wrong answer32ms16840 KiB
5Wrong answer34ms17928 KiB
6Wrong answer32ms18772 KiB
7Wrong answer34ms19828 KiB
subtask30/15
8Accepted4ms13240 KiB
9Accepted4ms13452 KiB
10Wrong answer4ms13692 KiB
11Wrong answer4ms13340 KiB
12Wrong answer4ms13344 KiB
13Wrong answer4ms13344 KiB
14Wrong answer4ms13348 KiB
subtask40/15
15Wrong answer4ms13628 KiB
16Wrong answer4ms13528 KiB
17Wrong answer4ms13652 KiB
18Wrong answer4ms13584 KiB
19Wrong answer4ms13772 KiB
20Wrong answer4ms13660 KiB
21Wrong answer4ms13664 KiB
subtask50/65
22Wrong answer50ms21388 KiB
23Wrong answer46ms22544 KiB
24Wrong answer46ms23696 KiB
25Wrong answer46ms24852 KiB
26Wrong answer46ms26000 KiB
27Wrong answer56ms36836 KiB
28Wrong answer61ms40516 KiB
29Wrong answer50ms34396 KiB
30Wrong answer48ms32936 KiB
31Wrong answer48ms32036 KiB
32Wrong answer46ms33324 KiB
33Wrong answer46ms34480 KiB
34Wrong answer37ms36252 KiB
35Wrong answer35ms37436 KiB
36Wrong answer37ms39008 KiB
37Wrong answer39ms40120 KiB
38Wrong answer39ms41580 KiB
39Wrong answer39ms42856 KiB
40Wrong answer41ms43928 KiB