FORGETPW - Editorial

In this line of your code(this can be a problem if your logic is correct…i haven’t checked yet…maybe there can be any other reason)

for(i=0;i<strlen(str);i++)
str[i]=arr[str[i]];

Here you are calculating the size of string in every iteration due to “strlen(str)” which is having time complexity of O(length(str)) making the time complexity of loop as O((length(str)) ^ 2)…
i was also getting TLE for same reason but thanks to a question on SPOJ and its forum that they told where I was making mistake

1 Like

I am getting .001 only…
You can check on this:

Hi,

My solution is http://www.codechef.com/viewsolution/4079595.My solution passed all the testcases successfully. Can you please help me to find the error with my solution.

http://ideone.com/ZtEEzT it is showing runtime error …

hi…I usually code in java…and I referred to the Editorialist’s solution for this problem. With all due respect, I think there is one case where the output’s not valid…

Input:

1

1

z .

343z.89

Output:
343…89

Well, is it or is it not a valid output ?

P.S. : No disrespect to anyone considering I’m just a newbie.

the input itself is invalid!!!

Thanks u help me a lot… I’m also getting TLE by this reason…

glad it helped you

The constraint actually states : " All characters in S and ci may be any ASCII printable character except space and pi is a digit (“0” - “9”) or a decimal point “.” "…I’m confused. How’s the input invalid ? Pls elaborate.

http://www.codechef.com/viewsolution/4102031 please any one find error in my code it runs on all expected test cases but still get wrong answer…

http://www.codechef.com/viewsolution/4046876

hey, guyz … i am new here … my solution is giving right answer for every test case but still WA . plzz can any one tell me my mistake or test case which i am missing … . please help me friends .

1 Like

“After all the character replacements, the string is guaranteed to be a positive decimal number”

1 Like

Why does this get tle?

FORGETPW my solution

I not have much knowledge of java but I think u are using s.length in loop condition so It increse your complexity to O(s.length^2). so separate calculate s.length and store in local variable and use as condition. For tle may be anY other reason…

@rudra_nitpsarraf ,No one mentioned it because “only” is written i.e, only factional part is present with no integral part… they also showed it using leading examples {(0.5=.5) and (5.0=5)}…

Thanks for answering but as far as I know the length function of a java string is O(1) because java’s string class stores the length as a field.

@dpraveen can u please check for which test cases , it is not working . i m not able to debug any further .

Is there any way to find out which test case a solution failed on? This was a pretty straight forward implementation but it got WA. http://www.codechef.com/viewsolution/4081801

Please help.Tried every possible case mentioned here.Still getting WA.

http://www.codechef.com/viewsolution/4114405

1 Like

All the sample test cases are passing. Also the corner case of “.”. However it is still giving wrong answer. Could somebody help?
http://www.codechef.com/viewsolution/4108137

1 Like