http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=50785
Translation: http://blog.csdn.net/acm_10000h/article/details/40988419
1#include <iostream>2#include <cstdio>3#include <cmath>4#include <vector>5#include <cstring>6#include <string>7#include <algorithm>8#include <string>9#include <Set>Ten#include <functional> One#include <numeric> A#include <sstream> -#include <stack> -#include <map> the#include <queue> - - #defineCL (arr, Val) memset (arr, Val, sizeof (arr)) - + #definell Long Long - #defineINF 0x7f7f7f7f + #defineLC L,m,rt<<1 A #defineRC M + 1,r,rt<<1|1 at #definePi ACOs (-1.0) - - #defineL (x) (x) << 1 - #defineR (x) (x) << 1 | 1 - #defineMID (L, R) (L + R) >> 1 - #defineMin (x, y) (x) < (y)? (x): (y) in #defineMax (x, y) (x) < (y)? (y): (x) - #defineE (x) (1 << (x)) to #defineIabs (x) (x) < 0? -(x): (x) + #defineOut (x) printf ("%i64d\n", X) - #defineLowbit (x) (x) & (-X) the #defineRead () freopen ("A.txt", "R", stdin) * #defineWrite () freopen ("B.txt", "w", stdout); $ #defineMAXN 1000000000Panax Notoginseng #defineN 1010 - using namespacestd; the inta[ the][10010]; + BOOLvis[ the]; A intN,m,ans; the + voidDfsintk) - { $ if(k==N) $ { - inttop=0; - for(intj=0; j<m;j++) the { - intCnt=0;Wuyi for(intI=0; i<n;i++) the { - if(!vis[i]&&a[i][j]| | VIS[I]&&!A[I][J])//note here, the front and back only one satisfies the condition, so in fact there is only one case of statistics. Wucnt++; - } About //printf ("%d\n", CNT); $Top+=max (cnt,n-CNT); - } -cn1=Max (Top,ans); - //printf ("%d%d\n", Top,ans); A return; + } thevis[k]=!Vis[k]; -DFS (k +1); $vis[k]=!Vis[k]; theDFS (k +1); the } the intMain () the { - //Read (); in //Write () the while(~SCANF ("%d%d", &n,&m) && (n+m)) the { About for(intI=0; i<n;i++) the for(intj=0; j<m;j++) scanf ("%d",&a[i][j]); thecn1=0; theCL (Vis,false); +Dfs0); -printf"%d\n", ans); the }Bayi return 0; the}
AOJ 0525-osenbei