272 - TEX Quotes

All about problems in Volume 2. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo »

You don't even pass the sample input..
See the sample output carefully..
CSEDU_1323
New poster
Posts: 10
Joined: Mon Feb 25, 2008 8:22 pm
Location: Dhaka, Bangladesh.

Post by CSEDU_1323 »

hi obaida,
initialize n=0 at d time of declaration

&&

use if(x==34&&s==1 )
instead if(x==34&&s==1&&i<length-1)

HOPE THIS HELP
--- B HAPPY & KEEP SMILING ------
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

STill WA..

Post by Obaida »

I edited my program... according jan's given input output.... This satisfy sample input and output... I took more coding to clear it out.....But still I got WA....

Code: Select all

Removed After AC....
}
Last edited by Obaida on Tue Mar 04, 2008 9:23 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Still WA..

Post by Obaida »

SOme one help me.... I couldn't think.... Is there any problem in understanding the problem..... Why this gives WA...?
try_try_try_try_&&&_try@try.com
This may be the address of success.
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Check the cases.

Input:

Code: Select all

"
"
"
"
Output:

Code: Select all

``
''
``
''
Hope these help.
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Easy...

Post by Obaida »

[/code]

I thought it so complex.... Now an easy code get Ac....Ha...Ha...Ha...
try_try_try_try_&&&_try@try.com
This may be the address of success.
The_Madman
New poster
Posts: 12
Joined: Fri May 23, 2008 10:24 pm

Re: 272 -Runtime Error-Plz help to debug it!!!

Post by The_Madman »

This is the program that i submitted to onlide judge. And as assumed(!) it replied with
"verdict Runtime error. This means that the execution of your program didn't finish properly. Remember to always terminate your code with the exit code 0."

Though all inputs and outputs are correct (as i guess) the main problem is when the strings get longer it crashes. Can anyone please tell how to solve it?

Yeah...yeah....solved it. Alhamdulillah!

was a string length problem.
like i let the string be determined in runtime, i.e., str[]={}
when i changed it to str[1000], i.e., in a fixed length the program executes and terminates successfully....and i got accepted.
can anyone explain this?? what if the length was greater than 1000? :o

regards
hahahaken
New poster
Posts: 26
Joined: Tue May 27, 2008 10:42 am

Re: 272 -WA-Plz help to debug it!!!

Post by hahahaken »

Do I need to consider the spaces and newlines in the output?
I have tried various methods to control the output but still don't manage to handle the spaces and newlines, but I think at most it should be presentation error
Why do I get wrong answer? Can anyone help take a look at it?

Code: Select all

Removed after AC
Last edited by hahahaken on Thu May 29, 2008 7:40 am, edited 1 time in total.
dreadlord
New poster
Posts: 19
Joined: Sat Apr 19, 2008 11:19 pm

Re: 272 -WA-Plz help to debug it!!!

Post by dreadlord »

This problem is extremely easy if one thinks in term of characters rather than lines.

WARNING: One program that gets AC follows (maybe not the best one in execution time, but AC). Do not read it if you still feel this problem as a challenge.

Code: Select all

Removed. Looks like it's not a good practice at all to post AC code...
All the best.

--Dread
Last edited by dreadlord on Thu Jun 05, 2008 1:13 pm, edited 1 time in total.
The_Madman
New poster
Posts: 12
Joined: Fri May 23, 2008 10:24 pm

Re: 272 -WA-Plz help to debug it!!!

Post by The_Madman »

To: hahahaken
Do I need to consider the spaces and newlines in the output?
No you don't. :D
Why do I get wrong answer? Can anyone help take a look at it?
Change the code below :
else if (s == '\'')

use numbers instead of '\''. You see the second apostrophe cancels the third one!
hahahaken
New poster
Posts: 26
Joined: Tue May 27, 2008 10:42 am

Re: 272 -WA-Plz help to debug it!!!

Post by hahahaken »

Still wrong answer, I hv changed the '\'' to char(39), but it doesn't work, why?

Code: Select all

Removed after AC
Last edited by hahahaken on Thu May 29, 2008 7:40 am, edited 1 time in total.
hahahaken
New poster
Posts: 26
Joined: Tue May 27, 2008 10:42 am

Re: 272 -WA-Plz help to debug it!!!

Post by hahahaken »

I have edited my code and submit a few times, but still wrong anssssss..., here's the lastest one, pls help :cry:
P.S. I've referred to the AC codes posted above, I think mine is similar to that, but I don't know what's wrong with mine
P.S.2 I have discovered that the single quotes should remain the same but my old version had changed the single quotes, that's why I got wrong ans, but even I have corrected this mistake, wrong answers still occur, why?

Code: Select all

Removed after AC
Last edited by hahahaken on Thu May 29, 2008 7:41 am, edited 1 time in total.
dreadlord
New poster
Posts: 19
Joined: Sat Apr 19, 2008 11:19 pm

Re: 272 -WA-Plz help to debug it!!!

Post by dreadlord »

hahahaken wrote:I have edited my code and submit a few times, but still wrong anssssss..., here's the lastest one, pls help :cry:
P.S. I've referred to the AC codes posted above, I think mine is similar to that, but I don't know what's wrong with mine
P.S.2 I have discovered that the single quotes should remain the same but my old version had changed the single quotes, that's why I got wrong ans, but even I have corrected this mistake, wrong answers still occur, why?

Code: Select all

...
hahahaken, I've made some tests with your last post code and I find two major problems:
  • 1) You never get a space nor end of lines. Sentence:

    Code: Select all

     cin >> s 
    will always get the input in a "tokenized" fashion. Try to add

    Code: Select all

     cout << "<<" << s << ">>"; 
    just as the first loop sentence to see what it's actually getting.

    2) As a result of the above, you won't ever detect either spaces or end of lines, so that you won't ever write them out as you should.
If I run your program with the following input:
this is just a "test" input
to check "hahahaken" 's program
I get the following output:
thisisjusta``test''inputtocheck``hahahaken'''sprogram
Instead of:
this is just a ``test'' input
to check ``hahahaken'' 's program
, which is the one it should give.

Hope this help.
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 272 -WA-Plz help to debug it!!!

Post by Obaida »

There is no trick in this problem. It's just straight forward.
read the string and run a loop from fast to last:
then if you find " then change to `` and if find " after `` then print ' ' else print that character.
to determine this things you can use a count initialized 0.
Increase count in every finding, When its even then print `` and when odd ' ' . very simple. :wink:
Last edited by Obaida on Wed May 28, 2008 12:59 pm, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.
hahahaken
New poster
Posts: 26
Joined: Tue May 27, 2008 10:42 am

Re: 272 -WA-Plz help to debug it!!!

Post by hahahaken »

Where should the below code added and what's the purpose?
I know how to output the spaces but I still don't manage to output line by line, I can just output a single continuous line, what else should I add?

Code: Select all

cout << "<<" << s << ">>"; 
Post Reply

Return to “Volume 2 (200-299)”