QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 256 MB 總分: 100

#22626. 波

统计

農夫 John の牛たちは、牧草地の隣の湖に小石を投げるのが大好きです。小石が湖面に当たると、湖面を伝わる波が発生します。

湖面は大きな正方形の格子で表します。各マスの水深は波の相互作用で決まります。石を投げる前は、元の川岸のマスを除くすべてのマスの水深が 0 です。表示には次を使います。

  • o:水深が 0 より小さいマス。

  • -:水深が 0 のマス。

  • *:水深が 0 より大きいマス。

  • X:元の川岸のマス。

小石を落とすと水面が上がる波が生じ、ひし形に毎秒拡大します。ひし形上の各マスの水深は 1 増えますが、それは一秒だけです。その二秒後に、水面が下がる波(水深を 1 減らす)が続き、同じくひし形に広がります。一つの石が生む波は二つだけで、上昇波の後に下降波が続きます。

例えば次の図は、湖の中央に石を落としてから 0、1、2、3 秒後の様子です。

0 seconds   1 second    2 seconds   3 seconds
 -------     -------     -------     ---*---
 -------     -------     ---*---     --*-*--
 -------     ---*---     --*-*--     -*-o-*-
 ---*---     --*-*--     -*-o-*-     *-o-o-*
 -------     ---*---     --*-*--     -*-o-*-
 -------     -------     ---*---     --*-*--
 -------     -------     -------     ---*---

図の各列は左から 0 秒、1 秒、2 秒、3 秒です。

川岸は固定の $x$ 座標を持ち、幅一マスで湖の全長(上から下)にわたります。波が川岸に達すると、そのまま通過せず、拡大を続けながら岸に当たった部分が反射します。

次は岸の一方に当たった波の初めの数秒です。見やすくするため、二つ目の下降波は省いています。

1 second    2 seconds   3 seconds   4 seconds   5 seconds
 X------     X------     X--*---     X-*-*--     X*---*-
 X------     X--*---     X-*-*--     X*---*-     X*----*
 X--*---     X-*-*--     X*---*-     X*----*     X-*----
 X-*-*--     X*---*-     X*----*     X-*----     X--*---
 X--*---     X-*-*--     X*---*-     X*----*     X-*----
 X------     X--*---     X-*-*--     X*---*-     X*----*
 X------     X------     X--*---     X-*-*--     X*---*-

図の各列は左から 1、2、3、4、5 秒です。

波の部分同士が出会っても互いの伝わり方には影響しません。次の時刻には、出会わなかった場合と同様に拡大します。ただし、湖に対する効果は合算されます。例えば次のようになります。

 1 second      2 seconds     3 seconds     4 seconds
 ---------     ---------     ---------     ---*-----
 ---------     ---------     ---*-----     --*-*-*--
 ---------     ---*-----     --*-*-*--     -*-o-*-*-
 ---*-----     --*-*-*--     -*-o-*-*-     *-o-----*
 --*-*-*--     -*-o-*-*-     *-o-----*     -o-*-o---
 ---*-----     --*-*-*--     -*-o-*-*-     *-o-----*
 ---------     ---*-----     --*-*-*--     -*-o-*-*-
 ---------     ---------     ---*-----     --*-*-*--
 ---------     ---------     ---------     ---*-----

図の各列は左から 1、2、3、4 秒です。

時間とともに波がどう広がるかを牛たちに教えるプログラムを書いてください。

入力

  • 1 行目:空白で区切られた四つの整数 $P$, $B1$, $B2$, $R$。

    • $P$ ($1 \le P \le 5$) は小石の個数です。

    • $B1$ ($-500{,}000 \le B1 \le 500{,}000$) と $B2$ ($-500{,}000 \le B2 \le 500{,}000$) は二つの川岸の $x$ 座標です。

    • $R$ ($1 \le R \le 500{,}000$) は湖を表示する時刻です。

二つの石が同じ時刻に同じ位置へ落ちることはありません。二つの岸の $x$ 座標は異なり、岸に石が落ちることもありません。

  • $2..P+1$ 行目:各行に石を表す空白区切りの三つの整数 $X$ ($-500{,}000 \le X \le 500{,}000$)、$Y$ ($-500{,}000 \le Y \le 500{,}000$)、$T$ ($1 \le T \le 500{,}000$)。

    • $X$ と $Y$ は石を落とす位置の座標です。

    • $T$ は石を落とす時刻です。

出力

  • 1~9 行目:$(0,0)$ を中心とする $9 \times 9$ の格子を出力します。左下は $(-4,-4)$、右上は $(4,4)$ です。時刻 $R$ の湖の状態を表してください。

入出力例

入力 1

2 4 100 4
-3 0 1
0 0 2

出力 1

--------X
-*------X
*-*-*---X
-o-*-*--X
o-----*-X
-o-*-*--X
*-*-*---X
-*------X
--------X

問題作成:Richard Forster、BIO 2003、2003

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.