Hello everyone!
I am a young programmer from Slovenia. I have participated in Facebook competition named Hacker Cup...
I hereby publish the C++ source code of task Peg Game with intension to share my knowledge with everyone. Code is about 65 lines long (or about 1250 charachers) without empty lines and comments.
The algorithm is optimal because each peg is calculated only once, so upper bound complexity is only O(r*c).
http://pastebin.com/CrxTFW3F
The solution is also very fast. I got these results on Core2duo @ 2.1, turning on O3 optimistion.
rok@rok-laptop:/var/www/hackercup/one/peg$ time ./peg < input.txt > output.txt
real 0m0.128s
user 0m0.120s
sys 0m0.000s
ponedeljek, 10. januar 2011
Naročite se na:
Objave (Atom)