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

Strelice

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

의견: 0

설명

1 \(s / 512\) \(MB / 160\) points

Hansel and Gretel are playing a we\(ll-kn\)own game of “Arrows” that takes place on a board
with R rows and S columns. On each field there is exactly one arrow that points to one of
the four main directions.

Hansel plays first, and his move is to colour exactly K fields on the board that are not
located in the final column. Gretel then places a robot on an arbitrary field in the first
column. Now the robot can move on his own, by moving from the current field to the field
that the arrow points to. If at some point the robot is located in the last column, he stops and
the game ends.

The winner of the game is determined in the following way:

If the robot stopped and the game ended, Hansel is the winner if the robot passed
through exactly one coloured field, and Gretel is the winner if the robot passed
through zero or more than one coloured fields.

If the robot did not stop after a finite amount of time (in other words, if the robot is
stuck in an infinite loop), Hansel is the winner.

We consider that the robot passed through the starting field, through the fields it moved on
throughout the game, and the field it was when the game ended. Also, the arrows will be
drawn so that the robot never exists outside the board’s boundaries.

Determine whether Hansel can ensure his victory no matter where Gretel initially places the
robot. If the answer is positive, output K fields he can colour in order to win.

제약
입력 형식

The first line of input contains the integers R, S, K (\(1 \le R * S \le 1\,000\,000\), \(1 \le K \le 50\)).
Each of the following R lines contains S characters ‘L’, ‘R’, ‘U’ or ‘D’ that denote the direction
of the arrow in the corresponding field of the board (\(L - le\)ft, \(R - ri\)ght, \(U - up\), \(D - do\)wn).

출력 형식

If Hansel cannot ensure his victory, outp\(ut -1\).
If Hansel can ensure his victory, output K lines. In each line, output spa\(ce-se\)parated
numbers A and B (\(1 \le A \le R\), \(1 \le B \le S\)) that denote the row and column of the field that
Hansel has to colour. All coloured fields must be different.
If multiple solutions exist, output any.

1 \(s / 512\) \(MB / 160\) points

예제 1
입력
4 3 1
DRD
DUD
DUD
RUL

3 3 2
RRR
RRR
RRR

4 4 2
RRDL
RRDL
DLRD
RRRL
출력
output
output
4 2

-1

2 3
4 1
설명

Clarification of the first test case:
If Hansel colours the field (4, 2), the robot will pass through it no matter where Gretel initially places it, so
Hansel will be the winner.

Clarification of the second test case:
Since Hansel must colour exactly 2 fields, this means that at least one of the three rows will not contain
a coloured field. Gretel can place the robot in that row and it will pass through 0 coloured fields, so
Gretel will win.

Clarification of the third test case:
Consult the image from the task.

문제 정보

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

출처 COCI 2016/2017 Contest 5

평가 및 의견

Strelice

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

Log in to rate problems.

개별 의견

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

풀이 제출

Strelice

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