## 10686 - SQF Problems

Moderator: Board moderators

helmet
New poster
Posts: 31
Joined: Tue Mar 02, 2004 11:55 am

### 10686 - SQF Problems

Pained by TLE
now WA

Someone help

~Thanks~
Just another brick in the wall...

little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm
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?

Revenger
Experienced poster
Posts: 132
Joined: Sun Apr 14, 2002 12:27 pm
Location: Russia
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]

Maniac
Experienced poster
Posts: 105
Joined: Tue Oct 14, 2003 3:24 pm
Location: Utrecht, Holland
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...

little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm
Well, that's exactly how I do it, so why WA???

[c]
/* CODE REMOVED, GOT AC */
[/c]
Last edited by little joey on Mon Aug 09, 2004 9:50 am, edited 2 times in total.

Per
A great helper
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden
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.

little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm
Hmm. I changed my program accordingly, but still WA.

Per
A great helper
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden
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 ).

little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm
It was my old code.
I finaly got AC. My problem was not reading the input correctly for the special cases
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...

Per
A great helper
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden
Ah, was just going to say that.

helmet
New poster
Posts: 31
Joined: Tue Mar 02, 2004 11:55 am

### Thanks

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?
Just another brick in the wall...

Maniac
Experienced poster
Posts: 105
Joined: Tue Oct 14, 2003 3:24 pm
Location: Utrecht, Holland
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.

Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong
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?
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org

little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm
No. The output should be:

Code: Select all

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

Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong
Why of course! Thanks very much~

(Actually I'm only interested of the 2nd case )
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org