View Code of Problem 122

#include <bits/stdc++.h>

using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        int root_edgeNum = 0;
        for (int i = 0; i < n - 1; i++) {
            int a, b;
            cin >> a >> b;
            if (a == 1 || b == 1) {
                root_edgeNum++;
            }
        }
        if (root_edgeNum % 2 == 0) {
            cout << "Bob" << endl;
        } else {
            cout << "Alice" << endl;
        }
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 122