結果

問題 No.232 めぐるはめぐる (2)
ユーザー 綾地寧々綾地寧々
提出日時 2015-06-26 23:27:06
言語 PHP
(8.3.4)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,456 bytes
コンパイル時間 360 ms
コンパイル使用メモリ 18,484 KB
実行使用メモリ 24,792 KB
最終ジャッジ日時 2023-09-22 01:40:31
合計ジャッジ時間 3,695 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 276 ms
22,712 KB
testcase_01 AC 293 ms
24,552 KB
testcase_02 AC 267 ms
22,824 KB
testcase_03 AC 268 ms
22,820 KB
testcase_04 AC 15 ms
18,664 KB
testcase_05 AC 14 ms
18,784 KB
testcase_06 AC 15 ms
18,700 KB
testcase_07 AC 15 ms
18,648 KB
testcase_08 AC 206 ms
24,792 KB
testcase_09 AC 15 ms
18,724 KB
testcase_10 AC 15 ms
18,788 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 15 ms
18,728 KB
testcase_14 AC 15 ms
18,708 KB
testcase_15 AC 17 ms
18,696 KB
testcase_16 AC 16 ms
18,764 KB
testcase_17 AC 15 ms
18,700 KB
testcase_18 AC 17 ms
18,768 KB
testcase_19 WA -
testcase_20 AC 15 ms
18,620 KB
testcase_21 AC 15 ms
18,732 KB
testcase_22 AC 15 ms
18,580 KB
testcase_23 AC 15 ms
18,512 KB
testcase_24 AC 16 ms
18,628 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
define("INPUT_UP", "^");
define("INPUT_DOWN", "v");
define("INPUT_LEFT", "<");
define("INPUT_RIGHT", ">");
list($t, $a, $b) = explode(" ",trim(fgets(STDIN)));
if ( max($a, $b) > $t ) {
	echo 'NO'.PHP_EOL;
	return;
}
$move_string = array_fill(0,$t,"");
// 上方向判定
for ( $i=0; $i<$a; $i++ ) {
	$move_string[$i] = INPUT_UP.$move_string[$i];
}
// 右方向判定
for ( $i=0; $i<$b; $i++ ) {
	$move_string[$t-$i-1] = INPUT_RIGHT.$move_string[$t-$i-1];
}
// 未入力タイミング回数のカウント
$no_input_count = 0;
foreach ( $move_string as $str ) {
	if ( strlen($str) == 0 ) {
		$no_input_count++;
	}
}
$odd_input_mode = 0;
// 未入力タイミングが1回しかなければあきらめてもらう
if ( $no_input_count == 1 ) {
	echo 'NO'.PHP_EOL;
	return;
}
// 未入力タイミングが奇数回なら同時押しで戻る戦法を使えば大丈夫
else if ( $no_input_count % 2 ) {
	$odd_input_mode = 3;
}
// 答え出力
echo 'YES'.PHP_EOL;
foreach ( $move_string as $str ) {
	if ( strlen($str) > 0 ) {
		echo $str;
	}
	else {
		if ( $odd_input_mode ) {
			switch ( $odd_input_mode ) {
				case 3:
					echo INPUT_RIGHT;
					break;
				case 2:
					echo INPUT_UP;
					break;
				case 1:
					echo INPUT_DOWN.INPUT_LEFT;
					break;
				default:
					break;
			}
			$odd_input_mode--;
		}
		else if ( !($no_input_count % 2) ) {
			echo INPUT_RIGHT;
		}
		else {
			echo INPUT_LEFT;
		}
		$no_input_count--;
	}
	echo PHP_EOL;
}
0