QOJ.ac

QOJ

Süre Sınırı: 2 s Bellek Sınırı: 256 MB Toplam puan: 100

#22626. 波浪

İstatistikler

農夫 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.