Page 10 of 17

195 - OLE

Posted: Wed Jul 13, 2005 10:42 pm
by elgeish
why OLE?

Code: Select all

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

bool cmp ( char a, char b ) { return (a|32) == (b|32) ? a >= 'A' && a <= 'Z' : (a|32) < (b|32); }

void main() {
// .... ACC
}

Posted: Sun Jul 17, 2005 7:40 am
by chunyi81
Your code goes into an infinite loop for the following input:

Input
1
AA

Correct Output
AA

The problem lies in the cmp function. Your code works for most cases, including repeated lowercase letters like this test case:

Input
1
aa

Output
aa

except test cases such as the first test case I posted above. Fix that bug and you should get AC.

Thnx

Posted: Sun Jul 17, 2005 9:44 pm
by elgeish
Thnx a lot, chunyi81, i got ACC now :)

What's difference between 195 & 10098

Posted: Fri Sep 09, 2005 5:46 am
by roni
my 10098 is acc. but get WA. Can anyone tell me their difference.
Any IO is usefull.

Posted: Fri Sep 09, 2005 9:36 am
by Dominik Michniewski
As I remember - it differs in output. And treating case of letters.

Best regards
DM

PS> Compare output and input definition sections in both problem.

got the casesencibility of 195

Posted: Sat Sep 10, 2005 12:29 am
by roni
i am very surprised how the case is treated in this problem(195). i got ur reply and taked to NAZMUL about it. Then i got ACC. So, thanks for help and reply DM.
------------------roni

Posted: Sat Oct 22, 2005 11:40 am
by Ming Han
I finally realise why I (and other ppl too) keep getting OLE...
input of aaaaaaaaaa
gives output of aaaaaaaaaa only.
Arg...

195 OLE -- CAN ANYONE GIVE ME SOME CRITICAL INPUT??

Posted: Fri Jan 06, 2006 5:40 pm
by afzal_du
I've tried many ways but still getting OLE. I've read previous posts but still could not find any cases where my code failed to produce the right output. Can anyone help me finding this?
Here is my code

Code: Select all

//acm195 Anagram
Removed After Acc.. 

Re: 195 OLE -- CAN ANYONE GIVE ME SOME CRITICAL INPUT??

Posted: Sun Jan 08, 2006 9:28 am
by tan_Yui
Your code seems good, but it's too small length to store the input string.
You will get 'Accepted' after changing the array size. :)
For example,

Code: Select all

1
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
when this input was coming, your code will handle illegal processes.

With my test, I think the size 100(or 99?) is enough for this problem.

Best regards.

Posted: Sun Jan 08, 2006 7:15 pm
by afzal_du
Thanks I've got acc now!
I thought that an array overflow will give a runtime error -- why ole??

195

Posted: Thu Mar 23, 2006 8:18 am
by Roby
Can someone give me hints or show where's my mistake from my code below:

Code: Select all

CUT AFTER AC
It did output correctly but why I got Runtime Error. Someone please help me...

Posted: Sat Mar 25, 2006 12:04 am
by serur
It seems to me you may mislay the possibility of input string being even longer than 100 characters, or if I am mistaken myself?
Anyway, I got this one accepted a week ago and I used malloc- i..e. without any assumptions about the length, simple stupid backtracking and a trick about "alphabetical order" not "ascii oredr"- all that is needed for this one 195 :)

Posted: Sun Mar 26, 2006 6:53 pm
by Roby
OK, I've changed my code but it gave me OLE. Here's my code:

Code: Select all

CUT AFTER AC
Does the comparer function do the correct things? I need hints here. Thanx in advance.

Posted: Sun Mar 26, 2006 8:42 pm
by serur
I don't feel quite sure about that, but I remember hearing somewhere that that what you have done int your grouping funcction(namely, returned char *r- address of a temporary variable) is not good...
though it may be not the case here, since OLE is caused by infinite loop...
Hope this will be of some help.
Your comparison function seems to be right, though I had troubles with compiling your code on my machine, only why don't you use islower() isupper( ) builtin functions of <ctype.h>? and 32='a'-'A' I guess...

Posted: Tue Mar 28, 2006 2:29 am
by Roby
Thanx for the help, finally I got AC :) I've just known that the islower/isupper is support in OJ.