結果

問題 No.24 数当てゲーム
コンテスト
ユーザー sorch
提出日時 2020-12-29 19:56:28
言語 PHP
(8.5.4)
コンパイル:
php -l _filename_
実行:
php _filename_
結果
AC  
実行時間 31 ms / 5,000 ms
コード長 700 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 102 ms
コンパイル使用メモリ 36,780 KB
実行使用メモリ 37,036 KB
最終ジャッジ日時 2026-04-21 08:05:40
合計ジャッジ時間 2,077 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #
raw source code

<?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