結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー ks2mks2m
提出日時 2020-01-31 21:39:34
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,059 bytes
コンパイル時間 4,455 ms
コンパイル使用メモリ 77,864 KB
実行使用メモリ 77,400 KB
最終ジャッジ日時 2023-10-17 08:59:30
合計ジャッジ時間 8,144 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
53,496 KB
testcase_01 AC 54 ms
53,496 KB
testcase_02 AC 54 ms
53,500 KB
testcase_03 AC 55 ms
53,504 KB
testcase_04 AC 55 ms
53,508 KB
testcase_05 AC 55 ms
53,504 KB
testcase_06 AC 54 ms
52,320 KB
testcase_07 AC 55 ms
53,508 KB
testcase_08 AC 57 ms
53,504 KB
testcase_09 AC 56 ms
53,512 KB
testcase_10 WA -
testcase_11 AC 55 ms
53,500 KB
testcase_12 AC 57 ms
53,500 KB
testcase_13 AC 151 ms
58,432 KB
testcase_14 AC 153 ms
58,404 KB
testcase_15 AC 164 ms
58,624 KB
testcase_16 AC 161 ms
58,600 KB
testcase_17 AC 170 ms
59,464 KB
testcase_18 AC 247 ms
61,740 KB
testcase_19 WA -
testcase_20 AC 286 ms
65,724 KB
testcase_21 AC 367 ms
67,040 KB
testcase_22 AC 459 ms
72,784 KB
testcase_23 AC 541 ms
77,384 KB
testcase_24 AC 567 ms
77,400 KB
testcase_25 AC 535 ms
75,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		List<List<Integer>> list = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<>());
		}
		for (int i = 0; i < n - 1; i++) {
			sa = br.readLine().split(" ");
			int u = Integer.parseInt(sa[0]);
			int v = Integer.parseInt(sa[1]);
			list.get(u).add(v);
			list.get(v).add(u);
		}
		br.close();

		boolean[] visit = new boolean[n];
		dfs(visit, list, 0);
		for (int i = 0; i < visit.length; i++) {
			if (!visit[i]) {
				System.out.println("Alice");
				return;
			}
		}
		System.out.println("Bob");
	}

	static void dfs(boolean[] visit, List<List<Integer>> list, int x) {
		visit[x] = true;
		for (int c : list.get(x)) {
			if (!visit[c]) {
				dfs(visit, list, c);
			}
		}
	}
}
0