RPLJ - Just the distance
Deisy is working on a robotics project, she wants to test the robot at the top before sending it to a very important company, she made a complete map for the robot, the robot is in the beta test, so it's a little dummy, the robot can't walk in diagonals, it only can walk in four directions; north, south, east or west, Deisy thinks someway this is a very bad thing, so, she wants to know if a diagonal is always the best path for the robot to go through.
You are going to test the robot's diagonal steps versus the real steps the robot can make from a map A to a map B, having in consideration that the robot can start whenever in map A or B and arrives to the nearest point in B or A, also, Deisy can choose any point as a start for the robot (this point will belong to a map) and you must not compare the set of points where the robot belongs.
Definition of a "map": a map is a set of stars (*) in adjacency, we define the adjacency as the four positions (north, south, east, west), meaning that a star is adjacent to other if they are communicated by one of these positions.
Input
The first line of input will contain an integer T denoting the T test cases, then, T cases will follow. Each of the following cases will contain a line with an integer N, then N lines with N characters each will follow, denoting the map the robot will have to traverse from a set of points A to a set of points B, a free space will be denoted by '-' and a occupied space by some point will be denoted by a character '*', it is guaranteed that there will be always two maps.
Output
Output the string “Scenario #i: “ where i is the test case you are analyzing followed by the option to choose, output 1 if the robot can go by its normal direction, 0 if going in diagonals is better.
Sample
INPUT 2 5 ---** ---** ----- **--- **--- 4 *--* *--* *--* *--* OUTPUT Scenario #1: 0 Scenario #2: 1
Explanation of the first case: For each point in the matrix either you start in map A or B, traversing in diagonals will always be better, the output should be zero (0).
Note: if Deisy find herself with equal distance between the diagonal and the "normal" steps of the robot, she will choose the "normal" steps as the best, in this case, the output should be 1 (normal is better).
Constraints
2<=N<=1000
hide comments
nadstratosfer:
2021-01-23 08:43:20
Horrible, unintelligible statement and full retard TL. In example given by psetter below, the 2 points in the left area he refers to cannot be used to reach the other area diagonally at all. Hence, min_diag_dist is the minimum distance between any two points in distinct areas on the same diagonal, and min_norm_dist is one between any two points in distinct areas using normal NESW traversal. This gets WA as well as measuring for every starting point separately and every other interpretation I could come up with. When one of the approaches got me TLE, spent some extra time to translate to C in order to fit in this idiotic limit, but got WA too. Bloody waste of time :( |
|
Afrizal:
2012-12-27 03:53:00
if we compare the distance between normal and diagonal, is there must be come from same start point? |
|
:D:
2012-05-14 17:14:48
Ok, so correct me if got anything wrong:
|
|
david_8k:
2012-05-14 13:43:33
@:D For diagonals, you just "move" to diagonals steps. (not the whole 8 directions).
|
|
:D:
2012-05-14 07:35:07
For diagonal can you move only in diagonal or in all 8 directions?
|
Added by: | david_8k |
Date: | 2012-05-05 |
Time limit: | 0.106s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Own Problem used for the RPL contest |