QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#290016#7786. Graft and Transplantwillow#WA 0ms3792kbC++14502b2023-12-24 08:37:522023-12-24 08:37:53

Judging History

你现在查看的是最新测评结果

  • [2023-12-24 08:37:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3792kb
  • [2023-12-24 08:37:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
const int N = 55;

int n, deg[N];

void solve() {
    scanf("%d", &n);
    for (int i = 1, u, v; i < n; ++i) {
        scanf("%d %d", &u, &v);
        ++deg[u];
        ++deg[v];
    }
    int leaf = 0;
    for (int i = 1; i <= n; ++i) {
        leaf += (deg[i] == 1);
    }
    int ans = n - 1 - leaf;
    puts(ans & 1? "Alice" : "Bob");
}

int main() {
    solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3616kb

input:

4
1 2
2 3
3 4

output:

Alice

result:

ok "Alice"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

4
1 2
1 3
1 4

output:

Bob

result:

ok "Bob"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3792kb

input:

2
1 2

output:

Alice

result:

wrong answer 1st words differ - expected: 'Bob', found: 'Alice'