9039: Cheeeeen the Cute Cat

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:5 通过:2

题目描述

*本题于2023/8/1增强了数据,之前提交的代码不重测。
Chen loves bipartite graph matching problems. As a cat, Chen also loves playing with woolen balls. So she thinks the graph should be dense.
And here's The Cute Cat Matching Problem:
Given a bipartite graph with 2n2n2n nodes and n(n−1)2\frac{n(n-1)}{2}2n(n1) edges, guaranteed that there are no edges between nodes 1,2,…,n{1,2,\dots,n}1,2,,n. There are no edges between nodes n+1,n+2,…,2n{n+1,n+2,\dots,2n}n+1,n+2,,2n too. Also, there's no edge between iii (1≤i≤n1\le i\le n1in) and i+ni+ni+n. If there's an edge between iii (1≤i,j≤n1\le i,j\le n1i,jn) and j+nj+nj+n, then there will be no edge between jjj and i+ni+ni+n. That means the given graph guarantees that there'll be exactly one edge between (i,j+n)(i,j+n)(i,j+n) and (i+n,j)(i+n,j)(i+n,j).
Help Chen find the maximum matching of the given graph.

输入格式

The first line contains one integer nnn (2≤n≤30002\le n\le 30002n3000), meanings the graph has 2n2n2n node.
For the next nnn lines, each line while contain nnn 010101s, forms a 010101 matrix eee (ei,j∈0,1e_{i,j}\in{0,1}ei,j0,1). If ei,j=1e_{i,j}=1ei,j=1, there will be an edge between node iii and n+jn+jn+j.

输出格式

One integer, means the maximum matching of the given graph.

输入样例 复制

2
0 1
0 0

输出样例 复制

1