結果
問題 |
No.806 木を道に
|
ユーザー |
![]() |
提出日時 | 2019-05-29 10:03:34 |
言語 | PHP (843.2) |
結果 |
AC
|
実行時間 | 90 ms / 2,000 ms |
コード長 | 563 bytes |
コンパイル時間 | 75 ms |
コンパイル使用メモリ | 32,404 KB |
実行使用メモリ | 38,456 KB |
最終ジャッジ日時 | 2024-09-17 15:58:18 |
合計ジャッジ時間 | 3,084 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php $n = trim(fgets(STDIN)); $node = array(); $target= array(); for( $i = 1; $i <= $n; $i++ ){ $node[$i] = 0; } $ans = 0; for( $i = 0; $i < ( $n - 1 ); $i++ ){ list( $a, $b ) = sscanf( trim(fgets(STDIN)), "%d %d" ); $node[$a]++; $node[$b]++; if ( $node[$a] > 2 ){ $target[] = $a; } if ( $node[$b] > 2 ){ $target[] = $b; } } $target = array_unique( $target ); foreach( $target as $v ){ $ans += $node[$v] - 2; } print $ans."\n";