Cod sursa(job #370661)
Utilizator | Data | 1 decembrie 2009 19:39:19 | |
---|---|---|---|
Problema | Jocul Flip | Scor | 0 |
Compilator | fpc | Status | done |
Runda | preoji2010 | Marime | 1.73 kb |
program joculflip;
uses wincrt;
var f,g:text;
a:array[1..16,1..16]of longint;
c,p,n,m,l,k,i,j:byte;
s,smax:longint;
begin
assign(f,'flip.in');
reset(f);
assign(g,'flip.out');
rewrite(g);
readln(f,n,m);
for i:=1 to n do
begin
for j:=1 to m do
read(f,a[i,j]);
readln(f);
end;
s:=0;
smax:=0;
repeat
p:=p+1;
for i:=n downto p do
begin
for j:=p to i do
for k:=1 to m do
a[j,k]:=a[j,k]*(-1);
c:=0;
repeat
c:=c+1;
for j:=m downto c do
begin
for k:=c to j do
for l:=1 to n do
a[l,k]:=a[l,k]*(-1);
s:=0;
for k:=1 to n do
for l:=1 to m do
s:=s+a[k,l];
if s>smax then
smax:=s;
for k:=c to j do
for l:=1 to n do
a[l,k]:=a[l,k]*(-1);
end;
until c=m;
for j:=p to i do
for k:=1 to m do
a[j,k]:=a[j,k]*(-1);
end;
until p=n;
writeln(g,smax);
close(f);
close(g);
end.