Select the number of n for different columns ... I'm telling you, two matches.
Two-point answer, then enumerate the range of edges and run Hungary to determine the range of answers.
#include <cstdlib> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm > #include <fstream> #include <iostream> #define REP (i, L, R) for (int. i=l; i<=r; i++) #define DOWN (i, L, R) for (int. i=l; i>=r; i--) #define N 123using namespace Std;int read () {int x=0, f=1; char Ch=getchar (); while (ch< ' 0 ' | | Ch> ' 9 ') {if (ch== '-') f=-1; Ch=getchar ();} while (ch>= ' 0 ' && ch<= ' 9 ') {x=x*10+ch-' 0 '; Ch=getchar ();} return x*f;} int N, L, R, M, Low, d[n][n], k[n];bool b[n];bool Find (int x) {Rep (i, 1, N) if (D[x][i]>=low && d[x][i]<=low+ M &&!b[i]) {b[i]=1; if (!k[i] | | Find (K[i])) {k[i]=x; return true;}} return false;} int main () {int t=read (), while (t--) {n=read (); Rep (i, 1, N) Rep (j, 1, N) d[i][j]=read (); int l=0, R=100;while (l!=r) {m= (l+r) /2; low=0; BOOL Can=false;while (low+m<=100) {bool Can2=true;rep (i, 1, N) k[i]=0;rep (i, 1, N) {rep (j, 1, N) b[j]=0;if (! Find (i)) {can2=false; break;}} if (can2) {can=true; Break }low++;} if (can) r=m; else l=m+1;} printf ("%d\n", L);} return 0;}
HDU-2236 Untitled II