結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー mino_yellowmino_yellow
提出日時 2022-11-16 01:14:16
言語 PHP
(8.3.4)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 630 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 32,784 KB
実行使用メモリ 61,396 KB
最終ジャッジ日時 2023-10-16 23:59:32
合計ジャッジ時間 3,528 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
32,876 KB
testcase_01 AC 42 ms
32,876 KB
testcase_02 AC 42 ms
32,876 KB
testcase_03 AC 43 ms
32,876 KB
testcase_04 AC 43 ms
32,876 KB
testcase_05 AC 42 ms
32,876 KB
testcase_06 AC 43 ms
32,876 KB
testcase_07 AC 42 ms
32,876 KB
testcase_08 AC 42 ms
32,876 KB
testcase_09 AC 42 ms
32,876 KB
testcase_10 AC 42 ms
32,876 KB
testcase_11 AC 42 ms
32,876 KB
testcase_12 AC 42 ms
32,876 KB
testcase_13 AC 50 ms
34,772 KB
testcase_14 AC 51 ms
36,820 KB
testcase_15 AC 51 ms
36,820 KB
testcase_16 AC 50 ms
34,772 KB
testcase_17 AC 52 ms
38,868 KB
testcase_18 AC 69 ms
40,916 KB
testcase_19 AC 70 ms
49,108 KB
testcase_20 AC 74 ms
49,108 KB
testcase_21 AC 93 ms
57,300 KB
testcase_22 AC 112 ms
61,396 KB
testcase_23 AC 152 ms
61,396 KB
testcase_24 AC 143 ms
61,396 KB
testcase_25 AC 151 ms
61,396 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
fscanf(STDIN,"%d",$N);
$cnt = array_fill(0,$N,0);
for($i=0;$i<$N-1;++$i){
    fscanf(STDIN,"%d%d",$a,$b);
    $d[$a][] = $b;
    $d[$b][] = $a;
    $cnt[$a]++;
    $cnt[$b]++;
}
$memo = array_fill(0,$N,false);
run($b);
$sum = array_sum($memo);
if($sum < $N-1){
    echo "Alice" . PHP_EOL;
}elseif($sum == $N-1){
    $two = 0;
    for($i=0;$i<$N;++$i) if($cnt[$i]==2) ++$two;
    if($two == $N-1) echo "Bob" . PHP_EOL;
    else echo "Alice" . PHP_EOL;
}else{
    echo "Bob" . PHP_EOL;
}
function run($now){
    global $memo,$d;
    if($memo[$now]) return;
    $memo[$now] = true;
    foreach($d[$now] as $to) run($to);
}


?>
0