解答一例
※正解ストーリーを読みたい方向け。
※いずれも設定は「PHP」とする。
正則表現のエントリーポイント
性能解析のタイプセーフ
例外処理のタブーサーチ
$currentParam) { $diff[] = $p[$index] - $currentParam; } $commandIndex = getCommandIndex($diff, $commands); $results[] = $commandIndex + 1; $currentParams = $p; } echo join("\n", $results); function getCommandIndex($paramDiff, $commands) { foreach ($commands as $cmdIndex => $cmd) { foreach ($paramDiff as $index => $diff) { if ($cmd[$index] != $diff) { continue 2; } } return $cmdIndex; } throw new Exception('技が存在しない'); } function getInputArrayFromStdin() { $inputArray = []; while ($input = trim(fgets(STDIN))) { $inputArray[] = $input; } return $inputArray; } function getInputArrayFromString($inputStr) { return explode("\n", str_replace(["\r\n", "\r", "\n"], "\n", $inputStr)); }
進化戦略のプロシージャ