103712024-04-01 15:31:05MagyarKendeSZLGÁtvágás (75 pont)cpp17Accepted 75/7552ms30960 KiB
#include <bits/stdc++.h>
using namespace std;

#define all(v) v.begin(), v.end()

int main() {
	cin.tie(0), ios::sync_with_stdio(0);

    int N;
    cin >> N;
    if (N <= 3) {
        cout << "0\n0";
        exit(0);
    }

    vector<int> indegS(N + 1);

    for (int i = 1; i < N; i++) {
        int U, V;
        cin >> U >> V;
        indegS[U]++;
        indegS[V]++;
    }

    int bambus = 0;

    for (int i = 1; i <= N; i++) {
        if (indegS[i] > 2) bambus += indegS[i] - 2;
    }

    cout << bambus << "\n" << N - 1 - *max_element(all(indegS));
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1824 KiB
2Accepted0/03ms1952 KiB
3Accepted0/04ms2492 KiB
4Accepted4/43ms2388 KiB
5Accepted4/43ms2464 KiB
6Accepted4/42ms2572 KiB
7Accepted4/42ms2544 KiB
8Accepted4/43ms2676 KiB
9Accepted4/43ms2764 KiB
10Accepted4/443ms6024 KiB
11Accepted4/448ms8016 KiB
12Accepted4/450ms10396 KiB
13Accepted4/452ms12904 KiB
14Accepted4/452ms15556 KiB
15Accepted4/452ms18088 KiB
16Accepted4/452ms20612 KiB
17Accepted4/452ms23256 KiB
18Accepted5/552ms25756 KiB
19Accepted6/652ms28324 KiB
20Accepted6/652ms30960 KiB
21Accepted2/23ms29396 KiB