Page 1 of 2

10686 - SQF Problems

Posted: Fri Aug 06, 2004 3:42 pm
by helmet
Pained by TLE
now WA

Someone help

~Thanks~

Posted: Sat Aug 07, 2004 3:46 pm
by little joey
Realy don't know. Have over 30 WAs trying different things. In my view everything is dependent on what exactly is a word.
Is "fun&games" one word? or two?
And what about "little_creaper", or "better4you", "me@home", "seven,eleven"? Is "(something)" the same as "something".
Should we ignore capitalization at the beginning of a sentence? Does interpunction mark the end of a word? Or only if followed by a space or newline? And what exactly are the interpunction characters? Just '.', ',', '?', '!', and ';'? Or others too?

All questions and no answers...

Posted: Sat Aug 07, 2004 5:51 pm
by Revenger
Word is a string formed only by 'a'..'z', 'A'..'Z'
fun&games - 2 words
better4you - 2 words

I used such code to parse the text

[pascal] s := s + ' ';
t := '';
for i := 1 to length(s) do
if s in ['a'..'z', 'A'..'Z'] then t := t + s else
if t <> '' then begin process_word(t); t := ''; end;[/pascal]

Posted: Sat Aug 07, 2004 5:54 pm
by Maniac
my guess: a word is a serie of characters in the range [a..z] union [A..Z]
And the problem states that all words should be treated case-sensitive. Does this logical assumption also give WA?

On speed, a hashtable would be enough I think...

Posted: Sat Aug 07, 2004 7:13 pm
by little joey
Well, that's exactly how I do it, so why WA???

[c]
/* CODE REMOVED, GOT AC */
[/c]

Posted: Sun Aug 08, 2004 2:51 pm
by Per
I'm pretty certain that the input contains categories which has repeated occurances of one or more keywords. E.g. inputs like:

Code: Select all

1
Graph 3 2
edge
edge
edge
We need an edge!
Where the output should be SQF Problem.

Posted: Sun Aug 08, 2004 10:22 pm
by little joey
Hmm. I changed my program accordingly, but still WA.

Posted: Sun Aug 08, 2004 11:16 pm
by Per
Hm, then I don't know what your problem is.
I actually skip spaces when checking for empty lines (like the part of your isempty function that is commented out), but that should only be an issue if the input is flawed.

Don't remember what your code looked like earlier, but if the above is the fixed version, you still don't handle inputs like the one in my previous post correctly (so I'm guessing that it is the unfixed version above :)).

Posted: Mon Aug 09, 2004 7:44 am
by little joey
It was my old code.
I finaly got AC. My problem was not reading the input correctly for the special cases :cry: :oops: :cry:
This input made me see my errors:

Code: Select all

7
0
There are no categories in here.

3
NeverOne 0 1
NeverTwo 1 2
dummy
NeverThree 2 2
dummy
dummy
This is a text where the word dummy apears twice!
Because I've added a dummy line.

2
AlwaysOne 0 0
AlwaysTwo 1 0
xantippe
Xantippe has a capital 'X'!

1
NoText 1 1
text

1
NoTextToo 0 0

0

1
Always 0 0
The previous case had no categories and no text.

Hope it helps someone...

Posted: Mon Aug 09, 2004 10:07 am
by Per
Ah, was just going to say that. :)

Thanks

Posted: Mon Aug 09, 2004 11:01 am
by helmet
I dont know what happened...But I think it was Per's suggestion that I remove empty spaces before I see end of line(ergo flawed input)

My prg got AC but I think there can be some change in judge for this.Atleast an enquiry?

Posted: Tue Aug 10, 2004 12:04 am
by Maniac
I thought I'd try this problem too and I got AC but after a lot more trials then I had hoped for :-|

I especially had trouble with handling the newline-characters. Only after explicitly reading them each time I expected one (with gets() and NOT with scanf("\n")) I got it right.... So I think that there are lines with whitespace before the newline-character where this was not to be expected.

Posted: Wed Aug 11, 2004 5:42 am
by Observer
little joey wrote:

Code: Select all

7
0
There are no categories in here.

3
NeverOne 0 1
NeverTwo 1 2
dummy
NeverThree 2 2
dummy
dummy
This is a text where the word dummy apears twice!
Because I've added a dummy line.

2
AlwaysOne 0 0
AlwaysTwo 1 0
xantippe
Xantippe has a capital 'X'!

1
NoText 1 1
text

1
NoTextToo 0 0

0

1
Always 0 0
The previous case had no categories and no text.

Excuse me, are those all SQF problems? :-?

Posted: Wed Aug 11, 2004 7:45 am
by little joey
No. The output should be:

Code: Select all

SQF Problem.
SQF Problem.
AlwaysOne,AlwaysTwo
SQF Problem.
NoTextToo
SQF Problem.
Always

Posted: Wed Aug 11, 2004 1:55 pm
by Observer
Why of course! Thanks very much~

(Actually I'm only interested of the 2nd case :-))