結果

問題 No.24 数当てゲーム
ユーザー sorchsorch
提出日時 2020-12-29 19:55:45
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 753 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 32,272 KB
実行使用メモリ 32,656 KB
最終ジャッジ日時 2024-04-15 19:54:23
合計ジャッジ時間 1,282 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 "$i : " . implode(' ', $candidates) . "\n";
}

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