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

Skakac

Diamond IV 다이아몬드 IV
난이도
1.500s
시간 제한
64MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Mirko and Slavko are playing the popular new game known as The Knight. Mirko places a knight chess piece on an \(N \times N\) chessboard and, with Slavko blindfolded, makes exactly \(T\) moves, one per second. After that, Slavko must guess the final position of the knight in order to win.

The chessboard in this game is unusual in that each square is blocked part of the time. More precisely, each square is labelled by a positive integer. A square labelled by number \(K\) is clear only during seconds \(0, K, 2K, 3K\) etc; it is blocked at all other times. The knight can, of course, occupy a square only while the square is clear.

The game begins in second \(0\). In each second Mirko must make a move (selecting one of \(8\) possible L-shaped moves, two squares in one direction and one square in the other, as per standard chess rules), provided that the destination square is not blocked during the next second. Help Slavko by writing a program to calculate all possible squares that the knight can possibly occupy after \(T\) moves.

제약

In test cases worth 40% of total points, the number of moves T will be less than 50 000.
\(1^{st}\) round, October \(22^{nd}\), 2011

입력 형식

The first line of input contains two positive integers, \(N\) (\(3 \le N \le 30\)), the size of the chessboard, and \(T\) (\(1 \le T \le 1\,000\,000\)), the number of moves that Mirko will make.

The second line of input contains two positive integers \(X\) and \(Y\) (\(1 \le X, Y \le N\)), the row and column indices of the knight's starting square selected by Mirko.

The next \(N\) lines each contain \(N\) positive integers less than \(10^9\) (one billion), the values of \(K\) for the corresponding chessboard squares.

출력 형식

The first line of output must contain the nonnegative integer \(M\), the number of squares that the knight can possibly occupy after \(T\) moves.

The next \(M\) lines must contain indices of those squares, sorted by increasing row index, with cells in the same row sorted by increasing column index.

Scoring: In test cases worth \(40\%\) of total points, the number of moves \(T\) will be less than \(50\,000\).

서브태스크
서브태스크점수설명

Test 1

10점

None

Test 2

10점

None

Test 3

10점

None

Test 4

10점

None

Test 5

10점

None

Test 6

10점

None

Test 7

10점

None

Test 8

10점

None

Test 9

10점

None

Test 10

10점

None

예제 1
입력
3 2
1 1
1 3 2
2 3 2
3 1 1
출력
2
1 1
1 3
예제 2
입력
5 6
2 3
4 5 3 2 3
1 3 4 3 1
3 4 1 3 2
4 4 2 1 3
4 6 4 9 2
출력
5
1 4
2 1
2 5
4 5
5 2
예제 3
입력
3 3
2 2
3 6 4
2 2 5
1 3 7
출력
0
문제 정보

riseoj 작성

출처 COCI 2011/2012 Contest 1

평가 및 의견

Skakac

개요
출제자 난이도 Diamond IV 다이아몬드 IV 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Skakac

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