Pagini recente » Cod sursa (job #3154343) | Cod sursa (job #3251552) | Cod sursa (job #1784761) | Cod sursa (job #1575607) | Cod sursa (job #2236378)
#include <bits/stdc++.h>
using namespace std;
ifstream f("flip.in");
ofstream g("flip.out");
int main()
{
int N,M,A[16][16];
f>>N>>M;
for(int i=0;i<N;i++)
for(int j=0;j<M;j++)
f>>A[i][j];
int smax=0;
for(int i=0;i<(1<<N);i++)
{
bitset<16> cX(i);
for(int j=0;j<(1<<M);j++)
{
bitset<16> cY(j);
int s=0;
for(int p=0;p<N;p++)
for(int q=0;q<M;q++)
{
s+=(cX[p]?-1:1)*(cY[q]?-1:1)*A[p][q];
}
smax=max(smax,s);
}
}
g<<smax;
return 0;
}