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

×

FORGETPW - Editorial

PROBLEM LINK:

Practice
Contest

Author: Gedi Zheng
Tester: Shiplu Hawlader
Editorialist: Praveen Dhinwa

DIFFICULTY:

Simple

PREREQUISITES:

processing of strings and arrays.

PROBLEM:

Given a string s, You have to replace some characters of it by a predefined mapping. After application of the mapping, it is guaranteed that you can read the string as a real number in base 10 notation. For a given number, you need to find its shortest notation. Please Have a look at explanation section to understand the definition of shortest notation.

EXPLANATION

Lets take some cases to understand what shortest notation of a real number means.

  • For 5.50, Last 0 is irrelevant. Shortest representation of it will be 5.5.
  • Similarly for 5.00, it will be 5.
  • For 00.5 it will be .5
  • For 00.00500 it will be .005
  • For 0000 it will be 0
  • For 500 it will be 500
  • For 00500 it will be 500

Now let us divide the situation into two cases.

  • If the number contains decimal mark.

    • Remove the starting few zero digits until we get a non zero digit (ie starting irrelevant digits).
      eg.
      In the case of 05, we need to remove starting 0 only. Its shortest representation will be 5
      In the case of 0.5, we need to remove starting 0 only. Its shortest representation will be .5

    • Find the point of occurrence of decimal mark, Remove the last irrelevant digits (zero digits) occurring after the decimal.
      eg.
      - If we are left with cases like 5.5550, then we need to remove the last zeros, So shortest representation will be 5.555

    • When the decimal is itself irrelevant, then we will remove the decimal too. You can see that decimal will be irrelevant if your number doesn't contain any relevant digit after the decimal point. eg.
      - In case of 5.00, We will remove both the zeros and decimal. Its shortest representation will be 5
      - In case of 5., We will remove the decimal. Its shortest representation will be 5

  • If the number does not contain decimal mark.

    • Remove the starting irrelevant digits. eg 0055500 will become 555000.
    • Note that lase zeros in this case are always relevant, You can not convert 550 to 55.
    • Special case: You need to take care of the case when the number is all 0's. Answer in that case will be a single 0.

Few Tricky Test Cases

  • Shortest representation for 0.00, .00, 0., 000, ., will be just a single 0
  • Shortest representation for 0, 00, 0(repeated x times) will be just a single 0
  • Shortest representation for 500.0, 500 will be 500
  • Shortest representation for 0.5, 00.50 will be .5

Complexity:
O(N), You just need to check above given conditions. You just need constant amount of passes over the string s.

AUTHOR'S AND TESTER'S SOLUTIONS:

Author's solution
Tester's solution
Editorialist's solution

This question is marked "community wiki".

asked 16 Jun '14, 15:01

dpraveen's gravatar image

4★dpraveen ♦♦
2.5k53137170
accept rate: 20%

edited 17 Jun '14, 17:44

1

did the test cases include many mappings to '.' ??

(17 Jun '14, 11:25) smiley0073★

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.....

(18 Jun '14, 17:46) jagdishbairer4★

I have checked all the test cases. but i am still not able to get successful submission. http://www.codechef.com/viewsolution/5135021

(12 Oct '14, 22:59) shefaliaj72★

@ praveen dhinwa,How one would know answer for '.' and '000.000' is 0 I was thinking that answer should be nothing but string should not be empty so this should not be the test case...(and I thought my codes were BAD!!!hehehehe ROFLMAO!!! )

  P.S. in the question, there was a statement:"If the number contains only non-zero fractional part, the integral part should be omitted." what i meant: e.g. 123.5=.5
@ praveen dhinwa,May i ask why i shouldn't mean this?
(FROM YOUR STATEMENT, 123.5=.5 IS CORRECT(i know it is weird!!))
And I was astonished why no one pointed this :( 
So, please don't write such misleading statements!!!
link

answered 16 Jun '14, 17:35

rudra_sarraf's gravatar image

3★rudra_sarraf
33621119
accept rate: 9%

edited 18 Jun '14, 20:05

1

Shortest representation of 000.000 should be 0. Empty string can not be a valid representation.

(17 Jun '14, 12:29) dpraveen ♦♦4★

and it was a decimal number ultimately..

(17 Jun '14, 16:48) sanzzzay2★

The question says shortest representation for 0.5 is .5 and for 5.0 it is 5. The question didn't mention about any order that we have to follow... So keeping both things in mind how can shortest representation of 0.0 be 0

(17 Jun '14, 17:38) insaynasasin1★

@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)}...

(18 Jun '14, 20:57) grayhathacker5★

@ PARTNER( :) ),If the number contains "only" non-zero fractional part, the integral part should be omitted." Then THAT "ONLY" itself means that there will be no integral part...isn't it??!!and if there is no integral part then what is the need of stating to delete integral part!!!

(19 Jun '14, 12:24) rudra_sarraf3★

I got the expected output for all the test cases given here.still i got wrong answer repeatedly. somebody plz help me out http://www.codechef.com/viewsolution/4057067 count1 and count2 denotes the number of digits to be removed from left side and right side respectively

link

answered 16 Jun '14, 15:53

minato_namikaz's gravatar image

1★minato_namikaz
5052311
accept rate: 10%

@minato_namikaz: 1 0 00. the o/p should be "0". ur code prints '.' - it is not a valid decimal number..

(17 Jun '14, 18:47) ksanoop532★

My solution is giving right answer for all the corner cases http://www.codechef.com/viewsolution/4099745

Can any one tell me why I was getting a WA. Any help would be appreciated.

link

answered 16 Jun '14, 17:32

codename007's gravatar image

2★codename007
162
accept rate: 0%

1 1 k l books not working for this test case, your code

(17 Jun '14, 00:02) brobear19952★

@brobear1995 1 1 k l Where is the encrypted string?

(17 Jun '14, 19:25) codename0072★
4

@brobear1995 okay i understood that encrypted string is books. but it was clearly mentioned in the problem "After all the character replacements, the string is guaranteed to be a positive decimal number." So as far as I understood, Test cases should be such that, after replacements it will be giving a decimal number. Please correct me if i'm wrong.

(17 Jun '14, 23:38) codename0072★
1

This should return 333, right? http://ideone.com/V5PZ7B

(19 Jun '14, 22:07) betlista ♦♦3★

@betlista: Thanks! will correct it now!

(21 Jun '14, 22:07) codename0072★

Yeah, just as @codename007 said, the statement stated that the number will be positive. I am quite certain, 0000.0000 or 0 is not a positive number. Right?

(24 Jun '14, 13:16) forthright4★
showing 5 of 6 show all

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 .

link

answered 18 Jun '14, 18:21

nikunj08's gravatar image

1★nikunj08
161
accept rate: 0%

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

link

answered 19 Jun '14, 08:47

jacobpjose's gravatar image

2★jacobpjose
16
accept rate: 0%

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

I was getting TLE. Where did my solution lose efficiency? Any help would be highly appreciated.

link

answered 16 Jun '14, 15:31

ar7thecoder's gravatar image

2★ar7thecoder
1
accept rate: 0%

@ar7thecoder you could have wrote it better. you are calculating leading and trailing zeroes for every string element which will give you a TLE. you can first decrypt the string and then calculate leading and trailing zeroes for the whole decrypted string. hope you get it now :)

(16 Jun '14, 15:41) shubham2343★

hi i got the expected output as above mentioned but still showed my answer as WA . Can you please help me with this and let me know which test case it was not woking . Any help is appreciated . http://www.codechef.com/viewsolution/4073838

link

answered 16 Jun '14, 16:19

anisdube's gravatar image

2★anisdube
161
accept rate: 0%

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

(18 Jun '14, 23:37) anisdube2★

http://www.codechef.com/viewsolution/4099249 WA anyone tell me how to correct error .

link

answered 16 Jun '14, 16:22

rkm123's gravatar image

2★rkm123
11
accept rate: 0%

@rkm123: Ur program works fine when there is only 1 test case.. but when 2 or more are given.. the results are wrong. 2 3 0 . . 9 5 0 95.0 0 01800 try the above one.... You will understand where you went wrong :)

(17 Jun '14, 18:58) ksanoop532★

I was continuously getting SEGABRT error for my answer.What may be the cause?In FAQ section,they say it may be occurring because STL elements are using too much memory.[I hadn't used any assert statement.]

link

answered 16 Jun '14, 16:25

tj2807's gravatar image

2★tj2807
1
accept rate: 0%

edited 16 Jun '14, 16:27

i think your case is not covering for the test case 000000000000 or 00000.000

(17 Jun '14, 17:10) sanzzzay2★

Plz help..always getting WA. Tried Several test cases.:( http://www.codechef.com/viewsolution/4106140

link

answered 16 Jun '14, 17:00

samsaurabh's gravatar image

2★samsaurabh
02
accept rate: 0%

edited 16 Jun '14, 17:31

1 2 e 9 i 8 8 0 ei for this test case your answer outputs 57 it should be 98. also it gives WA for many of the test cases. Try a bit more, you can get it correct.

(24 Jun '14, 14:12) brobear19952★

What whould hav been optimal way for replacement avoiding multiple replacements in the string

link

answered 16 Jun '14, 17:02

dragonwarior's gravatar image

2★dragonwarior
162
accept rate: 0%

just after one replacement flag them like for str[i] u have done replacement then take another bool array foo[100000] and at foo[i] make it equal to 1 and at the end of the loop again initialise all elements of array foo = 0;

(17 Jun '14, 17:13) sanzzzay2★

http://www.codechef.com/viewsolution/4106125 TLE....someone please help me out of this.i could not find out..and really want to know where am i crossing time bounds

link

answered 16 Jun '14, 17:29

anshubhuwania's gravatar image

2★anshubhuwania
1
accept rate: 0%

1

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

(18 Jun '14, 06:24) rock3219871★

Thanks u help me a lot.... I'm also getting TLE by this reason...

(18 Jun '14, 16:16) krish87644★

glad it helped you

(18 Jun '14, 16:31) rock3219871★

Can anybody help me why i got a TLE in this code?

I did the mapping using an array.

And while decryption, i kept a track of left-most-non-zero-digit, decimal-point-occurrence and right-most-non-zero-digit.

And later according to cases, displayed the output.

Why does it cause a TLE?

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

How was it inefficient? Thank you.

link

answered 16 Jun '14, 17:36

siddv29's gravatar image

2★siddv29
1124
accept rate: 0%

@siddv29 I guess you are using too many if statments for comparison resulting into TLE.The question doesn't require too many comparisons.

link

answered 16 Jun '14, 17:49

samsaurabh's gravatar image

2★samsaurabh
02
accept rate: 0%

edited 16 Jun '14, 17:49

Getting the right output for every testcase given here but still 'Wrong Answer'.Please help: http://www.codechef.com/viewsolution/4106245

link

answered 16 Jun '14, 18:08

phoenix94's gravatar image

2★phoenix94
1
accept rate: 0%

1

you have not used newline in printf as"\n" like for printf("0") u have to write like printf("0\n")

(17 Jun '14, 17:19) sanzzzay2★

http://www.codechef.com/viewsolution/4057659.. giving correct for test and tricky cases also http://ideone.com/4EA9kD but still wrong answer.. can some1 help

link

answered 16 Jun '14, 22:09

ab9999's gravatar image

2★ab9999
11
accept rate: 0%

what is your output for test case 1: 0 case 2 : 000000000000000000000

(17 Jun '14, 17:26) sanzzzay2★

its gives 0.. gives correct for tricky and normal tests.. the tested program is up on ideone link provided

(18 Jun '14, 00:16) ab99992★

it is showing runtime error in ideone see here http://ideone.com/zHklFb

(18 Jun '14, 00:35) sanzzzay2★

if u give 'space' instead of n.. it fails.. how should i correct it?

(19 Jun '14, 19:54) ab99992★

0 ≤ N ≤ 94 this constraint is given and u have used char x[30],y[30];that means to accomodate max 95 char u need array of atleast 95 size

(21 Jun '14, 10:53) sanzzzay2★

Can someone please tell me why I am getting a TLE? I have spent hours on this question but couldn't do it.. It clears all the tricky cases too btw http://www.codechef.com/viewsolution/4099816

link

answered 17 Jun '14, 01:25

parash93's gravatar image

2★parash93
12
accept rate: 0%

http://www.codechef.com/viewplaintext/4064994

Hey Guys,

I was getting TLE for the above solution, can someone tell what was wrong? Help would really be appreciated.

Thank You

link

answered 17 Jun '14, 09:57

vgshetty's gravatar image

2★vgshetty
1112
accept rate: 0%

A small correction, 0. and . themselves hold no meaning, as the question itself suggests that

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

link

answered 17 Jun '14, 13:17

wiseboy's gravatar image

2★wiseboy
129110
accept rate: 0%

my all test cases are working properly and have checked each and every possibility of test case that can be possible but it is still showing wrong answer. Here is my code. please someone go through it and help me out.

#include<stdio.h> #include<string.h>

int main()
{
int t,n,i,j,a,k,e,d,flag,flag1,b;
char s[1000001],c[127],p[127],m[1000001];
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf(" %c %c",&c[i],&p[i]);
}
scanf("%s",s);
flag=0;
flag1=2;
a=strlen(s);
if(n!=0)
{
for(i=0;i<a;i++)
{
for(j=0;j<n;j++)
if(s[i]==c[j])
{
s[i]=p[j];
break;
}
}
    }
for(i=0;i<=a;i++)
{ if(s[i]>'0' && flag==0)
{
flag=1;
j=i;
}
if(s[i-1]>'0' && s[i]=='0')
k=i-1;
else if(s[i-1]>'0' && s[i]=='\0')
k=i;
if(s[i]=='.' && flag==0)
{ flag1=0;
e=i;
}
if(s[i]=='.' && flag==1)
{ d=i;
flag1=1;
}
}
if(flag1==2)
{
for(i=j;i<a;i++)
m[i-j]=s[i];
}
else if(flag==1 && flag1==1)
{
if(k>d)
for(i=j;i<=k;i++)
m[i-j]=s[i];
else
for(i=j;i<d;i++)
m[i-j]=s[i];
}
else
{
for(i=e;i<=k;i++)
m[i-e]=s[i];
}
if(flag!=1)
printf("0\n");
else
printf("%s\n",m);
b=strlen(m);
for(i=0;i<b;i++)
m[i]='\0';
    for(i=0;i<n;i++)
c[i]='\0';
    for(i=0;i<n;i++)
p[i]='\0';
}

return 0;
}
link

answered 17 Jun '14, 14:15

tusharsre's gravatar image

3★tusharsre
11
accept rate: 0%

edited 17 Jun '14, 14:23

Check this....It works perfect. Give all the required solution. But give wrong ans.

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

link

answered 17 Jun '14, 19:52

srswain2's gravatar image

3★srswain2
1395612
accept rate: 0%

check this. its correct...but give WA in codechef

(21 Jun '14, 11:54) srswain23★

check your code here http://ideone.com/gXgNOa dont you think output of string 001800 should be 1800 ....:)

(24 Jun '14, 15:14) grvana1★

I am getting Runtime error for my java code. Can anybody help me with this?

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

link

answered 17 Jun '14, 20:39

ishanmanjani's gravatar image

2★ishanmanjani
1
accept rate: 0%

http://www.codechef.com/viewsolution/4110336 Can you please tell me for what case does this solution fail because it passes all the tricky cases mentioned here. Thanks in advance.

link

answered 17 Jun '14, 22:05

scrooge's gravatar image

2★scrooge
1
accept rate: 0%

what are you getting for test case 00.00100 ? once try to check it

(17 Jun '14, 22:13) sanzzzay2★

I am getting .001 only...... You can check on this: http://ideone.com/EyaibO

(18 Jun '14, 14:52) scrooge2★

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

(18 Jun '14, 15:10) sanzzzay2★

It will show runtime error because you have to enter N not the actual string after number of test cases.

(19 Jun '14, 10:26) scrooge2★

we can also used linked list for removing 0

link

answered 18 Jun '14, 01:24

mayur_shingote's gravatar image

2★mayur_shingote
1
accept rate: 0%

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.

link

answered 18 Jun '14, 14:59

rajes42's gravatar image

2★rajes42
1
accept rate: 0%

try for n=0 and s="000000000" you have not handled this case. It should give answer as 0 try to work on this case too. good luck..!!!

(19 Jun '14, 17:47) pmbhumkar2★

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.

link

answered 18 Jun '14, 15:52

aadya's gravatar image

2★aadya
11
accept rate: 0%

the input itself is invalid!!!

(18 Jun '14, 16:03) kunal3614★

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.

(18 Jun '14, 16:34) aadya2★
1

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

(18 Jun '14, 19:13) kunal3614★

Why does this get tle?
FORGETPW my solution

link

answered 18 Jun '14, 19:29

mohit22995's gravatar image

5★mohit22995
16114
accept rate: 20%

edited 18 Jun '14, 19:29

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.....

(18 Jun '14, 20:16) krish87644★

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.

(18 Jun '14, 21:25) mohit229955★

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

link

answered 19 Jun '14, 01:54

mikkanu's gravatar image

3★mikkanu
11
accept rate: 0%

try for 4 different cases which are mainly important n=0 s=0.0 , n=0 s=00000 , n=0 s=0000.120030000 and n=0 s=0000120000.0000 Still you want any case then try for '.' only good luck..!!!

(19 Jun '14, 17:52) pmbhumkar2★

@pmbhumkar - I'm getting expected result on all those tests: 0, 0, .12003, 0 Any other suggestions? It would really help to see exactly which test cases the code failed on.

(19 Jun '14, 21:11) mikkanu3★

Same situation here. Got 0, 0, .12003, 120000 and 0.But still gives wrong answer in system test.

(20 Jun '14, 08:04) jacobpjose2★

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

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

https://ideone.com/Em8m9I

link

answered 19 Jun '14, 03:22

rahulj123's gravatar image

1★rahulj123
153
accept rate: 0%

Your code has the same problem. http://discuss.codechef.com/questions/45391/forgot-password-input-test-cases is the answer that i have posted. Unfortunately you have down-voted my answer for no reason :(

(21 Jun '14, 08:56) bipin23★

this is my solution. can anybody tell me what's wrong with this solution. it passed all tricky test cases but still showing wrong answer. http://www.codechef.com/viewsolution/4119925

link

answered 20 Jun '14, 22:37

anilkraryan's gravatar image

2★anilkraryan
1
accept rate: 0%

My code works fine for all the input cases, I also tried my code with the tricky cases mentioned in the editorial but i am still getting WA. Can anyone please explain to me what the problem is. Code

link

answered 21 Jun '14, 01:55

skysarthak's gravatar image

3★skysarthak
453
accept rate: 0%

@dpraveen ♦♦ could you please help me here......thanxxx..

(23 Jun '14, 02:32) skysarthak3★
1

check your code http://ideone.com/vwfLid output should be 100 earlier i was also doing the same mistake....@sanzzzay pointed it out

(24 Jun '14, 15:20) grvana1★

@grvana for your help...i corrected the mistake you pointed out...but there still seems to be some prob as the code still gives WA on submitting....Revised code http://www.codechef.com/viewsolution/4139033

(24 Jun '14, 22:29) skysarthak3★

I'm getting a correct answer for every corner case, for every cases I read in the comments, yet getting a WA. Code Can someone help me to tell where is it that I am going wrong?

link

answered 22 Jun '14, 10:52

coder18694's gravatar image

4★coder18694
1
accept rate: 0%

edited 22 Jun '14, 10:54

getting WA after trying several test cases... http://www.codechef.com/viewsolution/4102057 ...can someone help..!!

link

answered 22 Jun '14, 15:13

tanaymathur4's gravatar image

2★tanaymathur4
11
accept rate: 0%

I am getting all test cases correct on my system still it is giving wrong answer ..please suggest what i am doing wrong.. http://www.codechef.com/viewsolution/4124811

link

answered 22 Jun '14, 16:37

arunima7kriti's gravatar image

3★arunima7kriti
1115
accept rate: 0%

check your code here http://ideone.com/aPoddj dont u think output should be 100 instead of 0

(24 Jun '14, 14:32) grvana1★

I'm just doing these for practice, but its really hard to call "." a "positive decimal number". Arguably its also hard to call "0" and "0.0" as a "positive decimal number" ("non-negative decimal number" would have been more appropriate), but I don't think that "." passes as a "positive decimal number" in any culture I'm aware of.

link

answered 23 Jun '14, 00:40

m1sterzer0's gravatar image

4★m1sterzer0
1215
accept rate: 0%

plz can anyone point out the error... http://ideone.com/5l8Jy2 i spent lot of time over it..(>_<)

link

answered 23 Jun '14, 20:02

grvana's gravatar image

1★grvana
152212
accept rate: 5%

edited 24 Jun '14, 14:44

@m1sterzer0 after reading your answer above...out of curiosity i checked your submission for the problem.... i dont know why its giving the wrong output instead of being accepted as right answer http://ideone.com/z1YyRR

link

answered 24 Jun '14, 15:51

grvana's gravatar image

1★grvana
152212
accept rate: 5%

http://www.codechef.com/viewsolution/3999376 This is my solution it is passing every case mentioned in the problem and every corner case as well. What is the problem here?

link

answered 25 Jun '14, 20:20

abhashksingh's gravatar image

2★abhashksingh
01
accept rate: 0%

I am getting wrong answer error.. please help..

include < iostream>

include < string>

using namespace std;

int main() {

int n;
cin>>n;
string  enPass,Pass;
while(n>0)
{
    int r,counter=0;
    cin>>r;   //  no. of rules.
    char c[r],p[r];
    for(int i=0;i<r;i++)
    {
        cin>>c[i]>>p[i];  // taking each rule as input
    }
    cin>>enPass;  // taking encrypted password as input
    Pass = enPass;
    for(int j=0;j<enPass.size();j++)
    {
        for(int s=0;s<r;s++)
        {
            if(c[s] == enPass[j])
            {
                Pass[j] = p[s];
            }

        }
    }

    int str_Size = Pass.size();
    for(int q = str_Size-1; q >= 0; q--)
    {
        if(Pass[q] == '0') Pass.erase(q);
        else if(Pass[q] == '.')
        {
            Pass.erase(q);
            break;
        }
        else break;
    }

   for(int t=0;t<str_Size;t++)
    {
        if(Pass[t] == '0') counter++;
        else break;
    }
   Pass.erase(0,counter);
    cout<<Pass<<"\n";
    n--;
}
return 0;

}

link

answered 26 Jun '14, 15:45

kishorer747's gravatar image

2★kishorer747
1
accept rate: 0%

I cracked this after trying different print techniques for the output. First, I print the op as separate characters(i.e every single S[i] using loop). This didn't work out. Secondly, I print the op as integers(using S[i]-'0' except for '.'). This didn't work out as well. Finally after going through the solution of @pummy02(https://www.codechef.com/viewsolution/7934954) I got a hint. I assigned the 'last+1'th char as null and printed the op as a string. This worked out!

link

answered 28 Sep '15, 22:02

vivekram's gravatar image

2★vivekram
313
accept rate: 0%

edited 28 Sep '15, 22:06

Can somebody help me with this solution, this gives correct answer for all the given tc but on submission gives wa. https://www.codechef.com/viewsolution/14346300

link

answered 26 Jun '17, 15:18

utsavgoel's gravatar image

2★utsavgoel
412
accept rate: 0%

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:

×15,852
×1,191
×968
×47
×21

question asked: 16 Jun '14, 15:01

question was seen: 5,911 times

last updated: 26 Jun '17, 15:18