Evil Blog Post

Posts   
 
    
psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 02-Jan-2007 18:55:16   

Frans,

Your post about Sphere Online Judge cost me half of my New Year's Day. wink

http://weblogs.asp.net/fbouma/archive/2006/12/29/sphere-online-judge-spoj-solve-really-hard-programming-problems-online.aspx

Very neat site--I enjoyed the one problem I did solve.

I managed to solve the problem I worked on with code that ran in 2 seconds using C#. I believe my solution was (at least) fairly efficient. Looking at the best solutions for the same problem, I see that several people solved it with code that ran in less than 0.2 seconds using C++.

Is C++ that much faster than C#? I realize that it's just as likely (or more likely) that my code is just not as efficient as I think.

Is there a way to profile .Net code to see what areas are slow? The whole thing runs in a single method if that makes a difference.

Thanks,

Phil

Walaa avatar
Walaa
Support Team
Posts: 14987
Joined: 21-Aug-2005
# Posted on: 03-Jan-2007 08:13:48   

A similar site: http://www.topcoder.com

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39797
Joined: 17-Aug-2003
# Posted on: 03-Jan-2007 09:28:13   

psandler wrote:

Frans,

Your post about Sphere Online Judge cost me half of my New Year's Day. wink Very neat site--I enjoyed the one problem I did solve.

Yeah it's very addictive simple_smile

I managed to solve the problem I worked on with code that ran in 2 seconds using C#. I believe my solution was (at least) fairly efficient. Looking at the best solutions for the same problem, I see that several people solved it with code that ran in less than 0.2 seconds using C++.

Is C++ that much faster than C#? I realize that it's just as likely (or more likely) that my code is just not as efficient as I think.

No, they use mono v1.0.1, which is VERY slow. I wrote a textstream to int array routine which barely made it possible to scan the input, left alone do something useful, so it's undoable at the moment to use C#. I posted on the forum to ask them if they could update to mono 1.2.

Is there a way to profile .Net code to see what areas are slow? The whole thing runs in a single method if that makes a difference. Thanks, Phil

I think it's best if you revert to C++ for the moment. Then you get decent load times, even with scanf, and you have enough time left for the algorithm.

@Walaa: I couldn't find any problem to solve on topcoder.com. Is topcoder a site which runs your solution as well? (I couldn't find info on that)

Frans Bouma | Lead developer LLBLGen Pro
Walaa avatar
Walaa
Support Team
Posts: 14987
Joined: 21-Aug-2005
# Posted on: 03-Jan-2007 14:00:21   

@Walaa: I couldn't find any problem to solve on topcoder.com. Is topcoder a site which runs your solution as well? (I couldn't find info on that)

go to the following link: http://www.topcoder.com/tc You can register using the button on the top-right corner of the screen. And you will find the competitions categories listed in the tree on the left side of the screen. Within each category (eg. algorithm) start by reading the FAQ.