logo AlgoBeat OnlineJudge
登录 注册

#212621. [UTS 2024] Randomized Palindromes

内存限制:256 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are given a binary matrix consisting of zeroes and ones. Initially, you have an empty string . You start in the position (left-up corner) and move right or down. You append each element you have passed to the string in the respective order.

Tell whether it is possible to achieve being a palindrome. If yes, print the way it should pass to achieve that.

Note that each matrix is randomly generated.

输入格式

The first line contains the only integer --- the size of a matrix.

The following lines contain the characters --- description of the matrix.

The input matrix for the problem is picked across all possible valid matrices for the problem of size .

输出格式

Print if there is no such palindrome.

Otherwise, in the first line, print . In each of the following lines, print two integers and () --- the coordinates of the -th cell.

样例

样例输入 1

2
01
00

样例输出 1

YES
0 0
0 1
1 1

样例输入 2

4
0100
1010
0100
0001

样例输出 2

NO

样例输入 3

4
0010
1001
1010
0010

样例输出 3

YES
0 0
0 1
0 2
0 3
1 3
2 3
3 3

数据范围与提示

  • ( points) ;
  • ( points) ;
  • ( points) ;
  • ( points) ;
  • ( points) no additional restrictions.