Mai intai trebuie sa te autentifici.
Cod sursa(job #2493520)
Utilizator | Data | 16 noiembrie 2019 13:31:22 | |
---|---|---|---|
Problema | Jocul Flip | Scor | 40 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.78 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin ("flip.in");
ofstream fout ("flip.out");
int n,sum,a[18][18],st[35],maxx,c,m;
void tipar()
{
sum=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
sum=sum+a[i][j]*st[i]*st[n+j];
}
}
if(c==0)
{
c++;
maxx=sum;
}
else
{
if(sum>maxx) maxx=sum;
}
}
void bck(int k)
{
for(int i=0;i<2;i++)
{
if(i==0) st[k]=-1;
else st[k]=1;
if(k==n+m) tipar();
else bck(k+1);
}
}
int main()
{
fin>>n>>m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
fin>>a[i][j];
}
}
bck(1);
fout<<maxx;
}