← Back to topics
Topic

z-ram

f
fushar
Any hint? Is this task solved with dp bitmask, or something else?
D
Dgleich
I need hint too..
g
gates
if you know which rows you'll take you can easy decide which columns are best for that selection of rows.
f
fushar
So, I must consider all 2^20 combination of rows?
f
fushar
how to know the columns? Do the naive O(n)?
D
Dgleich
hmm shouldn't you find n - number of rows columns taken
in O(n - number of rows taken * 20 * 20 ) which is too slow ?
g
gates
yes, you can try all combinations of rows and then in O( n ), ( n = 20 ) select columns
D
Dgleich
Ignore what I said I managed to confuse my self :D
h
halil
I have done the task, but it fails on test case 13 and 14. I can't generate that kind of test case where it shows me ''wrong result''.

Does anybody know what are like one of these test cases and result?
D
Dgleich
Can You tell your idea? I am looking at you code but it's hard to understand someone's code...
h
halil
(Slab sam sa engleskim, zato admine izvinjavam se zbog ovog posta).
Ideja je izbacitivati red ili kolonu sa najmanje jedinica, tj. u takav red/kolonu zamenjujem sa nulama. Ono sortiranje se moze izbrisati i zameniti funkcijom koja trazi red/kolonu sa najmanje jedinica (pa bi izvršenje bilo i brže). Jedino ne mogu da kreiram primer analogan 13 ili 14 testu kada dobijam WR.
D
Dgleich
Vrlo Dobro ideja :)
Dali je sigruno da ce to rjesenje raditi? mozda neki red ima manje 1 od drugog ali ima najvise jednica na mjestima koje ima i neki drugi red? pa ti onda izbacis taj a u stvari je on bolje rjesenje?
h
halil
Mislim da se ideja može doraditi. Ako neko ima svoje testove i rezultate, da li je voljan da mi pošalje?
g
gates
ideja nije dobra..mislim jasno ti je sigurno da postoji test primjer na kojem je kriva jer je to obican greedy
h
halil
OK. Thanks.
m
matijazzz
Can somebody tell me why my code isn't working?

program z_ram;

var
n,m,z,i,j,p,q,a,b:longint;
x:array [1..20,1..20] of char;

begin

readln(n);
for i:=1 to 20 do begin
for j:=1 to 20 do read(x[i,j]);
readln;
end;

m:=0;
for a:=1 to n-1 do begin
b:=n-a;
for i:=0 to 20-a do
for j:=0 to 20-b do begin
z:=0;
for p:=i+1 to i+a do
for q:=j+1 to j+b do
if (x[p,q] = '1') then z:=z+1;
if (z > m) then m:=z;
end;
end;

writeln(m);

end.

This code, when searching for 1s goes trough all matrix and gives correct results on 11 test cases, but get WR at 11th,12th,13th,14th test case ...