CF985B.Switches and Lamps

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are given nn switches and mm lamps. The ii -th switch turns on some subset of the lamps. This information is given as the matrix aa consisting of nn rows and mm columns where ai,j=1a_{i,j}=1 if the ii -th switch turns on the jj -th lamp and ai,j=0a_{i,j}=0 if the ii -th switch is not connected to the jj -th lamp.

Initially all mm lamps are turned off.

Switches change state only from "off" to "on". It means that if you press two or more switches connected to the same lamp then the lamp will be turned on after any of this switches is pressed and will remain its state even if any switch connected to this lamp is pressed afterwards.

It is guaranteed that if you push all nn switches then all mm lamps will be turned on.

Your think that you have too many switches and you would like to ignore one of them.

Your task is to say if there exists such a switch that if you will ignore (not use) it but press all the other n1n-1 switches then all the mm lamps will be turned on.

输入格式

The first line of the input contains two integers nn and mm ( 1<=n,m<=20001<=n,m<=2000 ) — the number of the switches and the number of the lamps.

The following nn lines contain mm characters each. The character ai,ja_{i,j} is equal to '1' if the ii -th switch turns on the jj -th lamp and '0' otherwise.

It is guaranteed that if you press all nn switches all mm lamps will be turned on.

输出格式

Print "YES" if there is a switch that if you will ignore it and press all the other n1n-1 switches then all mm lamps will be turned on. Print "NO" if there is no such switch.

输入输出样例

  • 输入#1

    4 5
    10101
    01000
    00111
    10000
    

    输出#1

    YES
    
  • 输入#2

    4 5
    10100
    01000
    00110
    00101
    

    输出#2

    NO
    
首页