Tetris Comes Back

Time Limit: 1000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 2280
64-bit integer IO format: %I64d      Java class name: Main

Description

Working in corporation is toilsome and rest is important. In leisure time, WisKey like to play Tetris. The Tetris game in board is N*5, and there are 8 kinds of blocks.
  Look that, red mean the area can’t be place. Other colors mean different kinds of blocks. If I give you C grey blocks (the 1st kind), and other infinite color blocks, Can you fulfil the board without any blocks overlap.

Input

Each case will contain two integers N (1<=N<=1000) and C (0<=C<=100).
N*5 grid follow it. The ‘1’ represent red area, it can’t be place. The ‘0’ represent normal area.
Process cases to end of file.

Output

If you can full of the Tetris, print “YES”, otherwise, print “NO”.

Sample Input

1 1
00000
1 1
00100
1 1
01010
4 1
10000
00101
10010
00000

Sample Output

YES
YES
NO
YES

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .