440 TLE?

All about problems in Volume IV. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

440 TLE?

Postby sami » Tue Jan 28, 2003 8:08 am

[cpp]

why i am getting TLE?[/cpp]
sami
New poster
 
Posts: 2
Joined: Tue Jan 28, 2003 7:25 am
Location: pakistan

Postby Dominik Michniewski » Tue Jan 28, 2003 9:05 am

I think, that's too litle informations to say why ;-)

Dominik
Dominik Michniewski
Guru
 
Posts: 828
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland

Postby sami » Sun Feb 02, 2003 4:28 pm

is there any speciality in its implementation or brute force is the solution..
sami
New poster
 
Posts: 2
Joined: Tue Jan 28, 2003 7:25 am
Location: pakistan

Postby gates1 » Tue May 01, 2007 8:31 pm

what's wrong in this, i getting WA

Code: Select all
var a:array[1..100] of shortint;
b:array[1..100] of byte;
i,j,u,z,k,n,r,l:longint;
begin
b[1]:=1;
repeat
inc(i);
readln(a[i]);
until a[i]=0;
n:=i-1;
for i:=1 to n do begin
r:=a[i];
j:=1;
repeat
inc(j);
l:=1;
k:=1;
for z:=2 to r do
b[z]:=0;
        repeat
        u:=0;
                repeat
                inc(l);
                if l=r+1 then begin
                l:=1;
                repeat
                inc(l);
                until b[l]=0;
                end;
                if b[l]=0 then inc(u);
                until u=j;
        b[l]:=1;
                inc(k);
        until k=r;
until l=2;
a[i]:=j;
end;
for i:=1 to n do
writeln(a[i]);
readln;
end.

gates1
New poster
 
Posts: 7
Joined: Tue May 01, 2007 2:11 pm

Re: 440 TLE?

Postby Obaida » Mon May 26, 2008 11:48 am

I have seen the ranking is 0.000 for this program. But my one is very slow :( !!!
I made a normal simulation to calculate the value. Is there any trick to find the value.
I hate such slow codes. :x
try_try_try_try_&&&_try@try.com
This may be the address of success.
Obaida
A great helper
 
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 440 TLE?

Postby plamplam » Thu Jun 16, 2011 7:56 pm

This is how you can get this code done in very short time. When I submitted this code for the first time, I got AC :D, but the runtime was 0.904 seconds. Then I realized that 3<=n<=150, and an idea suddenly struck my head. I removed scanf("%d",&n);
and the for loop was replaced with for(n = 3; n < 150; n++) from my original code. After I calculated the result, I simply printed printf("if(n == %d) printf("%d\n");", n, result); and copied the printed lines from the terminal and pasted them. I got AC in 0.08 seconds :D. It is impossible to get 0.000 runtime nowadays, it sucks lol.
Note you need to add an escape character before " and \n in order to print them. And try to find an optimized solution before you do this. But we all know that everything is fair in war and programming :wink:
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson
User avatar
plamplam
Experienced poster
 
Posts: 151
Joined: Fri May 06, 2011 11:37 am


Return to Volume IV

Who is online

Users browsing this forum: No registered users and 0 guests