QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 256 MB Total points: 100

#19997. ロボットとの子供の遊び

Statistics

これはインタラクティブな問題です。

小さな Misha はロボットと子供の遊びをしています。この遊びでは、ロボットは $3 \times 3$ 個のマスに分割され、周囲を境界で囲まれた場所に立っています。遊びは中央のマスから始まり、10 回の行動を行います。各行動は、フレーズを朗読するか、隣接するマスのいずれかへの移動を試みるかのどちらかです。朗読は待つため、または単に楽しむために使います。

マスの 1 つは特別なマスですが、Misha はどれなのかを事前には知りません。ロボットは特別なマスに入ると報告します。遊びの目標は、ちょうど 10 回目の行動で特別なマスに入ることです。

Misha はテキストの入出力でロボットとやり取りします。次のコマンドが認識されます。

  • echo phrase — phrase の朗読、

  • move north — 北に 1 マス移動、

  • move east — 東に 1 マス移動、

  • move south — 南に 1 マス移動、

  • move west — 西に 1 マス移動。

各朗読コマンドに対し、ロボットは指定されたフレーズを声に出して読み、同じ内容をテキストでも出力します。朗読中、ロボットは移動しません。ASCII コードが 32 から 126 まで(両端を含む)の文字からなり、長さが 256 文字以下のフレーズは、ロボットが正しく処理することが保証されます。

各移動コマンドに対し、ロボットは次の 4 つの単語のいずれかを出力します。

  • bump:移動する代わりに障害物にぶつかった場合。この場合、同じマスにとどまります。

  • moved:通常のマスへの移動に成功した場合。

  • found:最初の 9 回の行動のいずれかで特別なマスに移動した場合。

  • win:10 回目の行動で特別なマスに移動した場合。

10 回目の行動でロボットが目当ての単語 win を出力するように、Misha を手伝ってください。

インタラクション

解答プログラムは、標準出力に 1 行に 1 つずつコマンドを出力しなければなりません。出力がバッファに残るのを防ぐため、各コマンドの出力後に出力バッファをフラッシュしてください。例えば、C または C++ では fflush (stdout)、Java では System.out.flush ()、Pascal では flush (output)、Python では sys.stdout.flush () を使用できます。

各コマンドへの応答は、解答プログラムの標準入力にそれぞれ別の行で返されます。

10 個のコマンドを出力した後、解答プログラムは正常に終了しなければなりません。

入出力例

示した例では、特別なマスは中央の東側にあります。解答プログラムの検査では、このテストが最初に行われることが保証されます。

コマンド(解答プログラムの出力)を左側、それに対する応答(解答プログラムの入力)を右側に示しています。

入力 1

moved
moved
found
moved
found
bump
moved
Ready!
Steady...
win

出力 1

move north
move east
move south
move west
move east
move east
move south
echo Ready!
echo Steady...
move north

注記

各テストでは、特別なマスは事前に選ばれ、コンテスト中に変化することはありません。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.