ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1386. Maze

can someone help me?
Posted by Alexandar 26 Sep 2005 18:34
I really can't solve this task?
Alwaus got TLE on test 39 :-(
Can someone give me hint or ...
Re: can someone help me?
Posted by Kit (Vologda SPU) 26 Sep 2005 22:46
As for me, simpliest way is to use assembler instructions.
Re: can someone help me?
Posted by Burunduk1 27 Sep 2005 17:01
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?
Posted by Alexandar 30 Sep 2005 05:42
Still nothing :-(
This problem is driving me crazy!!!!
Re: can someone help me?
Posted by Ivankov Dmitry 30 Sep 2005 08:22
There is one optimization, that speeds up simple solution in about 5 times. So, keep on solving.
Re: can someone help me?
Posted by Alexandar 30 Sep 2005 18:24
Please send me some hint!!
Re: can someone help me?
Posted by ACM.Krupko_Victor[Ivanovo SPU] 1 Oct 2005 00:04
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?
Posted by ACM.Tolstobrov_Anatoliy[Ivanovo SPU] 1 Oct 2005 02:06

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?
Posted by [bsu] Poskunec 31 Jan 2008 23:44
Вообще если про скорость проверка if i mod m=0
все тормозит
k++;
if (k==m){
readln(p1,p2);
k=0;
}
else
read(p1,p2);
надо так
и еще очень ускоряет (покрайней мере у меня разные там битовые сдвиги)
Re: can someone help me?
Posted by bsu.mmf.team 6 Dec 2012 20:16
I wrote a starightforward O(N*M*S) solution without any optimizations and got AC.
Re: can someone help me?
Posted by Cebotari Vladislav 30 Dec 2016 15:00
Had TLE in java. Rewritten in C -> AC.