結果

問題 No.24 数当てゲーム
ユーザー sorchsorch
提出日時 2020-12-29 19:56:28
言語 PHP
(8.3.4)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 700 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 31,276 KB
実行使用メモリ 31,368 KB
最終ジャッジ日時 2024-04-15 19:54:38
合計ジャッジ時間 1,040 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
31,148 KB
testcase_01 AC 37 ms
31,252 KB
testcase_02 AC 37 ms
30,880 KB
testcase_03 AC 38 ms
31,116 KB
testcase_04 AC 37 ms
31,248 KB
testcase_05 AC 39 ms
31,220 KB
testcase_06 AC 38 ms
31,264 KB
testcase_07 AC 37 ms
31,216 KB
testcase_08 AC 39 ms
31,368 KB
testcase_09 AC 38 ms
30,920 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php

/**
 * @see https://yukicoder.me/problems/no/24
 */

$numTurn = trim(fgets(STDIN));
$numSet = range(0, 9);

$candidates = $numSet;
for ($i = 0; $i < $numTurn; $i++) {
    $splitArrays = array_chunk(explode(' ', trim(fgets(STDIN))), 4);
    $sayNums = $splitArrays[0];
    $response = $splitArrays[1][0];

    $candidates = extractCandidates($candidates, $sayNums, $response);
}

echo implode('', $candidates) . "\n";


function extractCandidates(array $candidates, array $sayNums, string $response): array
{
    switch ($response) {
        case 'NO':
            return array_diff($candidates, $sayNums);
        case 'YES':
            return array_intersect($candidates, $sayNums);
    }
}
0