当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2434:Waves

题目描述
Farmer John's cows thoroughly enjoy throwing pebbles into the lake next to their grazing field. When a pebble hits the surface of the lake, it generates a wave that propagates across the surface of the lake.

The surface of the lake is represented by a large grid of squares. The water at each square is at some depth, which is determined by the interaction of the waves. Before any pebbles are dropped, every square (except those on the original river banks) has a depth of 0. When displayed, each square will be represented as follows:
o Square has a depth < 0
- Square has a depth = 0
* Square has a depth > 0
X Square is part of the original river bank

When a pebble in dropped into the lake it causes a wave of raised water to spread out in a diamond pattern that grows every second. The depth of each square in the diamond is increased by 1 for just one single second. This wave is followed two seconds later by a wave of lowered water (depth decreased by 1) which also spreads out as a diamond. Each pebble causes only two waves, the raised wave followed by the lowered wave.

For example, the diagram below shows the effect of a pebble dropped in the middle of the lake at time intervals of 0, 1, 2 and 3 seconds:
after it is dropped:
0 seconds   1 second    2 seconds   3 seconds

------- ------- ------- ---*---
------- ------- ---*--- --*-*--
------- ---*--- --*-*-- -*-o-*-
---*--- --*-*-- -*-o-*- *-o-o-*
------- ---*--- --*-*-- -*-o-*-
------- ------- ---*--- --*-*--
------- ------- ------- ---*---

The river banks have fixed x co-ordinates and run for the entire length (top to bottom) of the lake with a width of a single square. When a wave reaches a river bank, rather than carrying on, it continues to grow but the part that hits the bank is reflected.

The early seconds of a wave hitting one of the river banks are shown below. To make the picture clearer, the second wave of lowered water is not shown:
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*---*-

When sections of waves meet they have no effect on the way each other propagates. In other words, at the next clock tick the waves will grow as though there was no encounter. Note however that their effects are combined on the lake. For example:
 1 second      2 seconds     3 seconds     4 seconds

--------- --------- --------- ---*-----
--------- --------- ---*----- --*-*-*--
--------- ---*----- --*-*-*-- -*-o-*-*-
---*----- --*-*-*-- -*-o-*-*- *-o-----*
--*-*-*-- -*-o-*-*- *-o-----* -o-*-o---
---*----- --*-*-*-- -*-o-*-*- *-o-----*
--------- ---*----- --*-*-*-- -*-o-*-*-
--------- --------- ---*----- --*-*-*--
--------- --------- --------- ---*-----

Write a program to help the cows figure out how the waves will spread out over time.
输入解释
* Line 1: Four space-separated integers: P, B1, B2, and R:
* P (1 <= P <= 5) indicates the number of pebbles,
* B1 (-500,000 <= B1 <= 500,000) and B2 (-500,000 <= B2 <= 500,000) are the x co-ordinates of two river banks, and
* R (1 <= R <= 500,000) the time at which you are to display the lake.
No two pebbles will be dropped at the same position at the same time. The two banks will have different x co-ordinates, and no pebble will be dropped on a bank.

* Lines 2..P+1: Each line contains three space-separated integers that describe a pebble: X (-500,000 <= X <= 500,000), Y (-500,000 <= Y <= 500,000), and and T (1 <= T <= 500,000)
* X and Y are the coordinates where a pebble is dropped
* T is the time at which the pebble is dropped
输出解释
* Lines 1..9: The output contains a 9 x 9 grid, centered on 0,0. The bottom left of the grid represents (-4, -4) and the top right represents (4,4). The grid should represent the state of the lake at time R.
输入样例
2 4 100 4
-3 0 1
0 0 2
输出样例
--------X
-*------X
*-*-*---X
-o-*-*--X
o-----*-X
-o-*-*--X
*-*-*---X
-*------X
--------X

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2434

最后修改于 2020-10-29T06:32:23+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536