Page 1 of 1

execution speed improving..

Posted: Fri Sep 08, 2006 2:06 pm
by a.souini
i would like to know if there is some kind of tips to make a C program run faster , i mean those for solving problems , and is the stats for some problem correct because i see that there is some peaple who got their code to solve the problems in 0:00.000 Cpu time :o .

Posted: Sun Sep 10, 2006 2:41 am
by jan_holmes
I think the one influenced the speed of the program is the algorithm you use to solve that. Except you use Java which needs longer run time than others.

Posted: Sun Sep 10, 2006 6:13 am
by Vexorian
Specially for the judge and in the case of C/C++(no stl) code, the algorithm's complexity is the most important factor about execution time.

You should get some good info about complexity and dynamic programming.

Edit: I got 0:00:00 many times, it is not actually 0:00:00 , what happens is that the judge is not accurate enough for low execution times. It also cannot measure memory either in short times. So, depending on how busy the judge is the same code can have 0:00:00/64 or 0:04:00/345 . You shouldn't care that much about CPU time time anyways, just make sure to beat the 10 seconds limit, in a contest it won't really matter if an algorithm is the fastest but how fast you submitted a correct solution without making mistakes / TLE.

Posted: Sun Sep 10, 2006 12:25 pm
by a.souini
thanks Vexorian and jan_holmes for your answers that clear up things :) , i really taught that 0:00:00 execution time is a real one , and for that matter i just learned that we have to decrease function calls in our C program or to use the '+' operation instead of the '*' operation as much as possible in order to make it faster .

Posted: Wed Sep 13, 2006 8:09 pm
by Moheeb
[/quote]
think the one influenced the speed of the program is the algorithm you use to solve that
[quote]

almost true . but there r so many ways to improve effeciency .u have to know ur particular machine architecture. plz look at the programming perls of John bently, one of the most beautiful book i have ever seen. also look at the following link :
http://www.azillionmonkeys.com/qed/optimize.html
:)

Posted: Wed Sep 13, 2006 8:13 pm
by jan_holmes
Thx for the addition, Moheeb... :)