Page 1 of 1

11619 - SPAM! (or not)

Posted: Sun Jun 16, 2013 12:11 pm
by mike21
Hello everybody,

I'm struggling to solve problem 11619.
I have coded it in Java, but I have a problem because I'm still getting WA.

Approach:
- use logarithm to calculate big formula
- assign probability spam/ham words (wordSpamFreq/totalSpamWords) or (wordFreqHam/totalHamWords).

Sample input:
MESSAGE SPAM
replica rolex
==
MESSAGE SPAM
replica rolex
==

P(replica/S) = 2/2 (it appears 2 times in 2 spam messages)
P(rolex/S) = 2/2
of course P(replica/H) = 0 & P(rolex/H) = 0.

I've also tried to assign P(replica/S) = 1, P (replica/H) = 0 but also not worked.

For sample input I'm getting this probabilities:

0.5
Unsure
0.9994837377387712
Spam
0.0019912881144990694
Ham

Any suggestion is helpful!

Thanks!

Re: 11619 - SPAM! (or not)

Posted: Tue Jun 18, 2013 2:48 am
by brianfry713
I just got AC. I'm not sure why you're using logarithm. Your probabilities are close to mine for the sample input. I used double variables in C++.

Try this input:

Code: Select all

MESSAGE SPAM
rolex rolex rolex rolex rolex rolex
==
MESSAGE HAM
Hello
==
MESSAGE CLASSIFY
Hello rolex
==
AC output:

Code: Select all

Unsure

Re: 11619 - SPAM! (or not)

Posted: Thu Jun 20, 2013 3:31 am
by brianfry713
Input:

Code: Select all

MESSAGE SPAM
rolex
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
==
MESSAGE CLASSIFY
rolex
==
AC Output: Spam

Re: 11619 - SPAM! (or not)

Posted: Thu Jun 20, 2013 1:30 pm
by mike21
Hi,

Many thanks for your posts. :) I've got ACCEPTED :D

Other possible test case:

Code: Select all

MESSAGE SPAM
replica
rolex
==
MESSAGE SPAM
replica   rolex
==
MESSAGE HAM
Hello all
==
MESSAGE CLASSIFY
Hello                 Replica
==
MESSAGE CLASSIFY
replica          rolex and 
some other things
==
MESSAGE CLASSIFY
abc
def   ghi jkl all
==
Output:
Unsure
Spam
Ham