CF243E.Matrix

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Let's consider an n×nn×n square matrix, consisting of digits one and zero.

We'll consider a matrix good, if it meets the following condition: in each row of the matrix all ones go in one group. That is, each row of the matrix looks like that 00...0011...1100...0000...0011...1100...00 (or simply consists of zeroes if it has no ones).

You are given matrix aa of size n×nn×n , consisting of zeroes and ones. Your task is to determine whether you can get a good matrix bb from it by rearranging the columns or not.

输入格式

The first line contains integer nn ( 1<=n<=5001<=n<=500 ) — the size of matrix aa .

Each of nn following lines contains nn characters "0" and "1" — matrix aa . Note that the characters are written without separators.

输出格式

Print "YES" in the first line, if you can rearrange the matrix columns so as to get a good matrix bb . In the next nn lines print the good matrix bb . If there are multiple answers, you are allowed to print any of them.

If it is impossible to get a good matrix, print "NO".

输入输出样例

  • 输入#1

    6
    100010
    110110
    011001
    010010
    000100
    011001
    

    输出#1

    YES
    011000
    111100
    000111
    001100
    100000
    000111
    
  • 输入#2

    3
    110
    101
    011
    

    输出#2

    NO
    
首页