Improved Hungary water over Ms ....
# Include <map> # include <set> # include <list> # include <queue> # include <deque> # include <stack> # include <string> # include <cstdio> # include <math. h> # include <iomanip> # include <cstdlib> # include <limits. h> # include <string. h> # include <iostream> # include <fstream> # include <algorithm> using namespace STD; # define ll long # define Min-99999999 # define Max 99999999 # define PII pair <int, int> # define bug cout <"He Re !! "<Endl # define PI ACOs (-1.0) # define fre freopen (" input.txt "," r ", stdin) # define FF freopen (" output.txt "," W ", stdout) # define EPS 1e-8 # define n 233 char STR [101]; int match [505] [1005]; // group number on the left, the right side is the number one int CNT [505]; int vis [505]; int G [505] [1005]; int n, m; int mid; bool sear (int s) {int I, j; for (I = 0; I <m; I ++) {If (G [I] [s] &! Vis [I]) {vis [I] = 1; if (CNT [I] <mid) {match [I] [CNT [I] ++] = s; return true;} else {for (j = 0; j <CNT [I]; j ++) {If (SEAR (Match [I] [J]) {match [I] [J] = s; return true ;}}}return false;} bool chk (INT mid) {int I, j; memset (CNT, 0, sizeof (CNT); for (I = 0; I <n; I ++) {memset (VIS, 0, sizeof (VIS); If (! Sear (I) return false;} return true;} void Gao () {int I, j; int L = 0, r = 1000; // binary answer while (L <r) {mid = (L + r)> 1; if (chk (MID) {r = mid ;} else l = Mid + 1;} printf ("% d \ n", L);} int main () {While (scanf ("% d", & N, & M) & (n + M) {// number of people, number of groups int I, j; getchar (); memset (G, 0, sizeof (g )); for (I = 0; I <n; I ++) {gets (STR); int Len = strlen (STR); For (j = 0; j <Len ;) {While (STR [J] <'0' | STR [J]> '9') {J ++;} int TMP = 0; while (STR [J]> = '0' & STR [J] <= '9') {TMP = TMP * 10 + STR [J]-'0 '; j ++;} G [TMP] [I] = 1; // each TMP group has multiple I} Gao ();} return 0 ;}