http://www.lydsy.com/JudgeOnline/problem.php?id=1059 (Topic link)
Test instructions
A 01 matrix that can exchange two or more columns arbitrarily, asking if the main diagonal is all 1 after several exchanges.
Solution
Hzwer: Peers with the same column no matter how many times the transformation still peers or the same column, so the title can be converted to find n different rows or the same column of points.
Code
bzoj1059#include<algorithm> #include <iostream> #include <cstdlib> #include <cstring># include<cstdio> #include <cmath> #include <queue> #define LL long long#define inf 10000000#define Pi ACOs ( -1.0) #define FREE (a) freopen (a ".", "R", stdin), Freopen (a ". Out", "w", stdout); using namespace Std;const int maxn= 300;int p[maxn],vis[maxn],f[maxn][maxn];int n,cnt;bool Match (int x) {for (int i=1;i<=n;i++) if (vis[i]!=cnt & & F[x][i] {vis[i]=cnt;if (!p[i] | | match (p[i])) {P[i]=x;return 1;}} return 0;} int main () {int t;scanf ("%d", &t), while (t--) {scanf ("%d", &n), and for (Int. i=1;i<=n;i++) for (int j=1;j<=n;j++) scanf ("%d", &f[i][j]), int ans=0;cnt=0;memset (p,0,sizeof (P)), memset (vis,0,sizeof (VIS)); for (int i=1;i<=n;i++ {cnt++;if (Match (i)) ans++;} if (ans==n) puts ("Yes"), Else puts ("No");} return 0;}
"bzoj1059" zjoi2007-matrix Game