236762026-01-27 13:00:29matemakaiÁtvágás (75 pont)cpp17Accepted 75/75143ms1332 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> deg(n);
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		++deg[a];
		++deg[b];
	}
	int star = n - 1, bamboo = 0;

	int max_deg = 0;

	for (int i = 0; i < n; ++i) {
		max_deg = max(max_deg, deg[i]);
	}

	star -= max_deg;

	for (int i = 0; i < n; ++i) {
		bamboo += max(0, deg[i] - 2);
	}

	cout << bamboo << " " << star << endl;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/01ms500 KiB
2Accepted0/01ms316 KiB
3Accepted0/07ms500 KiB
4Accepted4/41ms316 KiB
5Accepted4/41ms316 KiB
6Accepted4/41ms316 KiB
7Accepted4/41ms508 KiB
8Accepted4/41ms316 KiB
9Accepted4/41ms612 KiB
10Accepted4/4109ms1192 KiB
11Accepted4/4123ms1192 KiB
12Accepted4/4137ms1332 KiB
13Accepted4/4141ms1192 KiB
14Accepted4/4141ms1196 KiB
15Accepted4/4143ms1268 KiB
16Accepted4/4142ms1192 KiB
17Accepted4/4142ms1076 KiB
18Accepted5/5143ms1196 KiB
19Accepted6/6141ms1200 KiB
20Accepted6/6142ms1196 KiB
21Accepted2/21ms400 KiB