"); 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; }