結果

問題 No.24 数当てゲーム
ユーザー sorchsorch
提出日時 2020-12-29 19:49:52
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 699 bytes
コンパイル時間 1,736 ms
コンパイル使用メモリ 30,692 KB
実行使用メモリ 31,508 KB
最終ジャッジ日時 2024-04-15 19:49:20
合計ジャッジ時間 964 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
30,968 KB
testcase_01 AC 44 ms
31,124 KB
testcase_02 AC 41 ms
31,012 KB
testcase_03 AC 42 ms
31,092 KB
testcase_04 AC 38 ms
31,112 KB
testcase_05 WA -
testcase_06 AC 38 ms
31,164 KB
testcase_07 AC 37 ms
31,124 KB
testcase_08 AC 43 ms
31,188 KB
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(1, 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