結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー nanophoto12nanophoto12
提出日時 2020-02-01 00:00:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,439 bytes
コンパイル時間 2,789 ms
コンパイル使用メモリ 211,616 KB
実行使用メモリ 4,848 KB
最終ジャッジ日時 2023-10-17 13:56:56
合計ジャッジ時間 3,927 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 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 WA -
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 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 7 ms
4,348 KB
testcase_14 AC 7 ms
4,348 KB
testcase_15 AC 7 ms
4,348 KB
testcase_16 AC 7 ms
4,348 KB
testcase_17 WA -
testcase_18 AC 19 ms
4,348 KB
testcase_19 WA -
testcase_20 AC 32 ms
4,348 KB
testcase_21 AC 49 ms
4,560 KB
testcase_22 AC 63 ms
4,824 KB
testcase_23 AC 64 ms
4,824 KB
testcase_24 WA -
testcase_25 AC 64 ms
4,824 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~

ソースコード

diff #

#pragma once

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ll mod = 1000000007;

struct UnionFind {
public:
	vector <ll> par; // 
	vector <ll> siz; // 

	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}

	ll root(ll x) {
		while (par[x] != x) {
			x = par[x] = par[par[x]];
		}
		return x;
	}

	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool issame(ll x, ll y) {
		return root(x) == root(y);
	}

	ll size(ll x) {
		return siz[root(x)];
	}
}; 

int main(void)
{
	ll n;
	cin >> n;
	UnionFind uf(n);
	rep(i, n-1) {
		ll a, b;
		cin >> a >> b;
		uf.merge(a, b);		
	}
	unordered_map<ll,ll> s;
	rep(i, n) {
		s[uf.root(i)]++;
	}
	if (s.size() > 2) {
		cout << "Alice" << endl;
	}
	else if(s.size() == 1){
		cout << "Bob" << endl;
	}
	else {
		for (auto e : s) {
			if (e.second == 1) {
				cout << "Bod" << endl;
				return 0;
			}			
		}
		cout << "Alice" << endl;
	}
	return 0;
}
0