10686 - SQF Problems

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

Moderator: Board moderators

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

10686 - SQF Problems

Post by helmet » Fri Aug 06, 2004 3:42 pm

Pained by TLE
now WA

Someone help

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

User avatar
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey » Sat Aug 07, 2004 3:46 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?

All questions and no answers...

Revenger
Experienced poster
Posts: 132
Joined: Sun Apr 14, 2002 12:27 pm
Location: Russia

Post by Revenger » Sat Aug 07, 2004 5:51 pm

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

Post by Maniac » Sat Aug 07, 2004 5:54 pm

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

User avatar
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey » Sat Aug 07, 2004 7:13 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

Post by Per » Sun Aug 08, 2004 2:51 pm

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.

User avatar
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey » Sun Aug 08, 2004 10:22 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

Post by Per » Sun Aug 08, 2004 11:16 pm

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

User avatar
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey » Mon Aug 09, 2004 7:44 am

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

Per
A great helper
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden

Post by Per » Mon Aug 09, 2004 10:07 am

Ah, was just going to say that. :)

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

Thanks

Post by helmet » Mon Aug 09, 2004 11:01 am

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

Post by Maniac » Tue Aug 10, 2004 12:04 am

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

Post by Observer » Wed Aug 11, 2004 5:42 am

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

User avatar
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey » Wed Aug 11, 2004 7:45 am

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

Post by Observer » Wed Aug 11, 2004 1:55 pm

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

Post Reply

Return to “Volume 106 (10600-10699)”