You are not logged in. Please login at www.codechef.com to post your questions!

×

Beat by bit

I tried these two problems in yesterday's contest Bit by Bit. First one gave WA and second one TLE. The TLE problem is my first shortest path program. Is there any way to optimize it or is there another approach for the problem? Also, why am I getting WA in first one where approach is same as the ones used by other contestants?

Problem and WA solution
Problem and Solution TLE

asked 02 Mar '15, 18:38

dragonemperor's gravatar image

3★dragonemperor
89321135
accept rate: 10%


Here is your corrected code for first question Problem1. What you did wrong was did not take care of repeated characters in input string.

Your second answer does not work as it has a complexity of O(n^2), which clearly would not work as n<=10^4. You should try Dijkstra's Algorithm as it takes O(n log n) time.

link

answered 02 Mar '15, 20:32

thechamp103's gravatar image

3★thechamp103
597411
accept rate: 16%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×729

question asked: 02 Mar '15, 18:38

question was seen: 740 times

last updated: 02 Mar '15, 20:32