RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00255

Voyager

Unrated 레이팅 미적용
난이도
1s
시간 제한
32MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

\(4^{th}\) round, January \(19^{th}\), 2013

The Voyager 1 space probe (not to be confused with the Intrep\(id-cl\)ass starship) was launched a long
time ago, in 1977, and is currently on the verge of leaving our Solar System. As it travels further
through space, it has been programmed to leave a radio signal message in any star system it stumbles
upon, to mark the probe's path for as long as possible.
Let us assume that a star system can be represented by a rectangular grid with N rows and M
columns, dividing the space into N by M equal cells. Each cell can contain a single planet, black
hole, or be empty. The probe broadcasts the signal from a p\(re-de\)termined empty cell, in one of the
four ax\(is-al\)igned directions (“U”-up, “R”-right, “D”-down, “L”-left).
Upon being broadcast, the signal propagates in a straight line along the same r\(ow/co\)lumn until it
reaches a planet, where it is deflected by 90 degrees in another direction. There are two kinds of
planets, which we will denote by „/“ and „\“. The deflection rules are shown in the image below:

The signal permanently leaves the system upon either entring a cell containing a black hole, or
propagating outside the edges of the rectangular grid. It is also known that the signal needs one second
to propagate from the current cell to a neighbouring one.
Write a program to determine the direction in which the probe needs to broadcast the signal so that it
remains within the system for as long as possible, outputting the optimal direction as well as the
resulting longest time. If it is possible for the signal to remain in the system indefinitely, output the
message „Voyager“ instead of the required time.

제약

In test data worth at least 50% of total points, the signal will not be able to remain in the system
indefinitely.

입력 형식

The first line of input contains two positive integers, N (\(1 \le N \le 500\)) and M (\(1 \le M \le 500\)).
Each of the following N lines contains M characters from the set {“/”, “\”, “C”, “.”}, where “/” and
“\” represent the two kinds of planets, “C” represents a black hole, and “.” represents an empty cell.
The last line of input contains two positive integers, PR (\(1 \le PR \le N\)) and PC (\(1 \le PC \le M\)), the row
and column number, respectively, of the cell where the probe is situated.

출력 형식

The first line of output must contain the required optimal broadcast direction (“U”, “R”, “D”, or “L”).
If the solution is not unique, select the first optimal one in the following priority order: first “U”, then
“R”, then “D”, and finally “L”.
The second line of output must contain the required longest time (or message).
\(4^{th}\) round, January \(19^{th}\), 2013

예제 1
입력
5 5
../.\
.....
.C...
...C.
\.../
3 3
출력
U
17
예제 2
입력
5 5
....\
\..\.
./\..
\../C
.\../
1 1
출력
D
12
예제 3
입력
5 7
/.....\
../..\.
\...../
/.....\
\.\.../
3 3
출력
R
Voyager
설명

Clarification of the first example ("*" represents the path of the singal):

start
../.\
.....
.CS..
...C.
.../

'U' direction
.
.
.
C.
..C


17 seconds
'R' direction
../.\
.....
.C***
...C.
.../

3 seconds
'D' direction
../.\
.....
.C..
..
C.
.*./

3 seconds
'L' direction
../.\
.....
.C*..
...C.
.../

1 second

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2012/2013 Contest 4

평가 및 의견

Voyager

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Voyager

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8