|
|
вернуться в форумcan someone help me? I really can't solve this task? Alwaus got TLE on test 39 :-( Can someone give me hint or ... Re: can someone help me? As for me, simpliest way is to use assembler instructions. Re: can someone help me? There are some optimizations like this: Bad code: for (x = 0; x < W; x++) for (y = 0; y < H; y++) A[y][x] = 1; This code works much faster than previous one: for (y = 0; y < H; y++) for (x = 0; x < W; x++) A[y][x] = 1; Re: can someone help me? Still nothing :-( This problem is driving me crazy!!!! Re: can someone help me? There is one optimization, that speeds up simple solution in about 5 times. So, keep on solving. Re: can someone help me? Please send me some hint!! Re: can someone help me? a:array[1..4,1..10000] of word; for k:=1 to 4 do for i:=1 to n*m do begin if i mod m=0 then readln(p1,p2) else read(p1,p2); a[k,i]:=(p1-1)*m+p2; end; this be fast Re: can someone help me? i think it more faster :) a:array[1..4,101..10100] of word; for k:=1 to 4 do for i:=1 to n*m do begin if i mod m=0 then readln(p1,p2) else read(p1,p2); a[k,i]:=p1*m+p2; end; Re: can someone help me? Вообще если про скорость проверка if i mod m=0 все тормозит k++; if (k==m){ readln(p1,p2); k=0; } else read(p1,p2); надо так и еще очень ускоряет (покрайней мере у меня разные там битовые сдвиги) Re: can someone help me? I wrote a starightforward O(N*M*S) solution without any optimizations and got AC. Re: can someone help me? Had TLE in java. Rewritten in C -> AC. |
|
|