시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 (추가 시간 없음) | 1024 MB | 48 | 25 | 23 | 51.111% |
You are taking a course on machine learning at your university, and as homework you have been tasked with writing a program that can tell vertical bars from horizontal bars in images. To generate some training data, you use the following method. First, take an $N \times N$ grid, and fill it with zeros. Next, take a row or a column, and fill it with ones. Finally, take at most $N$ arbitrary cells, and flip them. Flipping a cell means changing a zero to a one, or changing a one to a zero.
Generating data this way is easy, but how to generate all the answers? It will take hours to go through the training data manually. If only you had a program that finds all the outputs automatically somehow.
You are given an $N \times N$ matrix that has been generated as in the description. Write a program that finds whether it was a column or a row that was filled with ones, or if it is impossible to determine.
The first line of input consists of an integer $N$ ($2 \leq N \leq 1000$), the size of the grid.
The following $N$ lines each contain a string of length $N$ consisting of zeros and ones. These are the rows of the grid.
It is guaranteed that the input was generated by taking a grid of zeros, putting ones on a row or a column, and then flipping at most $N$ cells.
If the bar was vertical (a column), print "|
". If it was horizontal (a row), print "-
". If it is impossible to determine (because it could be both), print "+
".
5 01100 01000 01001 00000 01000
|
3 111 000 111
-
3 010 101 010
+
Contest > KTH Challenge > KTH Challenge 2022 H번