0 人解决,0 人已尝试。
0 份提交通过,共有 0 份提交。
9.9 EMB 奖励。
单点时限: 2.0 sec
内存限制: 256 MB
Oh no! The delicate political balance of the world has finally collapsed, and everybody has declared war on everybody else. You warned whoever would listen that this would happen, but did they pay attention? Ha! Now the only thing you can hope for is to survive as long as possible.
Fortunately (sort of), everyone’s industrial centers have already been nuked, so the only method of attack available to each nation is to hurl wave after wave of conscripted soldiers at each other. This limits each nation to attacking only its immediate neighbors. The world is a R-by-C grid with R rows, numbered from 1 in the far North to R in the far South, and C columns, numbered from 1 in the far West to C in the far East. Each nation occupies one square of the grid, which means that each nation can reach at most 4 other adjacent nations.
Every nation starts with a specific strength value, known to everyone. They have no concept of advanced strategy, so at the beginning of each day, they will simply choose their strongest neighbor (breaking ties first by Northernmost nation, then by Westernmost) and attack them with an army. The army will have a power equal to the current strength S of the nation; by the end of the day, it will have depleted that neighbor’s strength by S. A nation whose strength reaches 0 is destroyed. Note that all nations attack at the same time; an army’s power is the same regardless of whether its nation is attacked that day.
Your nation is located at (c, r), in row r and column c. Fortunately, your nation is listening to your advice, so you don’t have to follow this crazy strategy. You may choose to attack any of your neighbors on a given day (or do nothing at all). You can’t attack multiple neighbors, however, or attack with an army of less than full power.
Determine the maximum number days you can survive.
The first line of input gives the number of cases, T(1 ≤ T ≤ 100). T test cases follow. The first line of each test case contains four integers, C(1 ≤ C ≤ 50), R(1 ≤ R ≤ 50), c(1 ≤ c ≤ C), and r. The next R(1 ≤ r ≤ R) lines each contain C integers, giving the starting strength Sci,ri(0 ≤ Sci,ri ≤ 1000) of the nation in column ci and row ri. It may be 0, indicating that the nation has already been destroyed. Your nation’s starting strength will not be 0.
For each test case, output one line containing “Case #A: ” followed by:
2 3 3 2 2 2 3 2 1 7 1 2 1 2 4 3 2 1 1 2 2 0 10 8 5 10 10 2 9 10
Case #1: forever Case #2: 3 day(s)
0 人解决,0 人已尝试。
0 份提交通过,共有 0 份提交。
9.9 EMB 奖励。