#P4304. [TJOI2013] 攻击装置

    ID: 3248 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2013各省省选二分图最大流天津

[TJOI2013] 攻击装置

Description

Given a 0-1 matrix, you can place an attack device on any cell with value 0. Each device at (x,y)(x,y) can attack in a knight’s move the following 8 positions: (x1,y2)(x-1,y-2), (x2,y1)(x-2,y-1), (x+1,y2)(x+1,y-2), (x+2,y1)(x+2,y-1), (x1,y+2)(x-1,y+2), (x2,y+1)(x-2,y+1), (x+1,y+2)(x+1,y+2), (x+2,y+1)(x+2,y+1). Find the maximum number of devices that can be placed so that no two devices attack each other.

Input Format

The first line contains an integer NN, meaning the matrix size is N×NN \times N.
The next NN lines each contain a binary string of length NN, representing the matrix.

Output Format

Output a single integer, the maximum number of devices that can be placed so that no two devices attack each other.

3
010
000
100
4

Hint

For 30%30\% of the testdata, it is guaranteed that N50N \le 50.
For 100%100\% of the testdata, it is guaranteed that N200N \le 200.

Translated by ChatGPT 5