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

Skandi

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

의견: 0

설명

Dragica is a captain of a local se\(mi-pr\)ofessional bowling team, she is a passionate chef and probably
one of the best crossword puzzle solvers in Croatia. A crossword puzzle consists of \(N \times M\) squares
arranged in \(N\) rows and \(M\) columns. Some of the squares are empty (and should be filled with letters
by answering questions) and some of the squares are filled. Filled squares contain at most two questions
which should either be answered horizontally to the right or vertically downwards. The answers to the
questions are written in the empty squares before until we reach the crossword bound or an initial\(ly-fi\)lled
square. An initial\(ly-fi\)lled square contains a horizontal question if a square to the right exists and is empty.
Analogously, an initial\(ly-fi\)lled square contains a vertical question if a square beneath it exists and is
empty.
Dragica usually knows all the answers to the crossword puzzle questions, but wishes to read and answer
as little questions as possible and still solve the entire crossword puzzle. Help her achieve her goal.

제약

Subtask
Score
Constraints
1
18
There will be at most 9 squares with ’1’
2
32
\(N \le 500\) and \(M \le 10\)
3
60
No additional constraints.
If your solution outputs the first line correctly on each test case of a subtask, but it fails to correctly
output the other lines in some test case, you will score 50% of the allocated points for that subtask.

입력 형식

The first line contains integers \(N\) and \(M\) (\(2 \le N\), \(M \le 500\)) from the task description.
Each of the next \(N\) lines contain \(M\) characters ‘0’ or ‘1’, where ‘0’ denotes an empty square which
should be filled by answering a question and ’1’ denotes an initially filled square which may contain at
most two questions as explained in the task description. The first row and first column will be filled with
‘1’ characters.
It is guaranteed that there will be at least one character ’0’ in the input.

출력 형식

In the first line you should output the minimal number of questions that can be answered in order to
solve an entire crossword puzzle. Let’s denote that number with \(X\).
Each of the next \(X\) lines should describe one question that should be answered. The question description
should be printed in the format R C direction, where \(R\) is the row number of the question, \(C\) is the
column number of the question and direction is either "DESNO" (Croatian for RIGHT) or "DOLJE" (Croatian
for DOWN) depending on whether Dragica should answer the vertical or horizontal question.
If there are multiple solutions, output any of them.

예제 1
입력
4 5
11111
10000
10000
10000
출력
3
2 1 DESNO
3 1 DESNO
4 1 DESNO
예제 2
입력
6 4
1111
1011
1000
1011
1010
1000
출력
4
1 2 DOLJE
4 4 DOLJE
5 3 DOLJE
3 1 DESNO
예제 3
입력
9 8
11111111
10000000
10001000
10010001
11100001
10100110
10001000
10100001
10010001
출력
14
5 2 DOLJE
5 8 DOLJE
8 3 DOLJE
2 1 DESNO
3 1 DESNO
3 5 DESNO
4 1 DESNO
4 4 DESNO
5 3 DESNO
6 3 DESNO
7 1 DESNO
7 5 DESNO
8 3 DESNO
9 4 DESNO
설명

Clarification of the third example: An example of a real crossword puzzle which is equivalent to the
one described in this example is given on the next page. Initially-filled squares are colored black and those
squares that contain at least one question are numerated. Below the puzzle you can see the questions
that should be solved to-the-right (column "across") and those that should be solved downwards (column
"down"). Note that some initially-filled squares contain no questions, some contain a single question (e.g.
8 and 13), while some contain two questions (e.g. 10 and 12). In order to solve this crossword puzzle you
need to know the answers to at least 14 questions that are listed in the output. Can you solve it?

문제 정보

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

출처 COCI 2019/2020 Contest 6

평가 및 의견

Skandi

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

Log in to rate problems.

개별 의견

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

풀이 제출

Skandi

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