結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー wait_sushiwait_sushi
提出日時 2020-01-31 21:46:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,911 bytes
コンパイル時間 1,893 ms
コンパイル使用メモリ 178,864 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2023-10-17 09:08:04
合計ジャッジ時間 3,615 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 10 ms
4,388 KB
testcase_15 AC 9 ms
4,384 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 31 ms
6,624 KB
testcase_20 AC 51 ms
7,348 KB
testcase_21 AC 82 ms
9,056 KB
testcase_22 AC 112 ms
10,368 KB
testcase_23 AC 112 ms
11,136 KB
testcase_24 WA -
testcase_25 AC 109 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
bool chmin(ll& a, ll& b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll& b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
vl V;
struct Gragh {
    ll N;
    vector<vl> G;
    vl visited;

    Gragh(ll n) {
        N = n;
        G.resize(N);
        resetv();
    }

    void add(ll a, ll b) { G[a].push_back(b); }

    void resetv(void) { visited = vl(N, 0); }

    //重さ無し
    void dfs(ll x, ll a) {
        visited[x] = 1;
        for (ll i : G[x]) {
            if (visited[i] == 0) {
                dfs(i, a + 1);
            }
            else V.push_back(a);
        }
    }
};
int main() {
    cin >> n;
    Gragh G(n);
    rep(i, n-1) {
        cin >> a >> b;
        G.add(a, b);
        G.add(b, a);
    }

    rep(i, n) {
        if (!G.visited[i]) {
            G.dfs(i, 0);
            k++;
        }
    }

    sort(all(V));
    reverse(all(V));

    if (k > 2) {
        cout << "Alice" << endl;
    }
    else if (k == 2&&V[0]==n-3) {
        cout << "Alice" << endl;
    }
    else {
        cout << "Bob" << endl;
    }
}
0