QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#793104#7786. Graft and TransplantchenjiaqiyWA 1ms3640kbC++20953b2024-11-29 16:43:102024-11-29 16:43:18

Judging History

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

  • [2024-11-29 16:43:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3640kb
  • [2024-11-29 16:43:10]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define endl '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define x first
#define y second
#define debug(_x) cout << #_x << '=' << _x << endl
typedef pair<int, int> PII;
using i64 = long long;
const int mod = 998244353;
const int N = 1e5 + 10, M = 20;

vector<int> g[N];

void solve()
{
    int n;
    cin >> n;
    for (int i = 1; i < n; i++)
    {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        if (g[i].size() == 1)
            cnt++;
    }
    if ((n - cnt) & 1)
    {
        cout << "Bob";
    }
    else
        cout << "Alice";
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int _ = 1;
    // cin >> _;

    while (_--)
        solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3576kb

input:

4
1 2
2 3
3 4

output:

Alice

result:

ok "Alice"

Test #2:

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

input:

4
1 2
1 3
1 4

output:

Bob

result:

ok "Bob"

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3640kb

input:

2
1 2

output:

Alice

result:

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