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!
11619 - SPAM! (or not)
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11619 - SPAM! (or not)
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:AC output:
Try this input:
Code: Select all
MESSAGE SPAM
rolex rolex rolex rolex rolex rolex
==
MESSAGE HAM
Hello
==
MESSAGE CLASSIFY
Hello rolex
==
Code: Select all
Unsure
Check input and AC output for thousands of problems on uDebug!
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11619 - SPAM! (or not)
Input:AC Output: Spam
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
==
Check input and AC output for thousands of problems on uDebug!
Re: 11619 - SPAM! (or not)
Hi,
Many thanks for your posts.
I've got ACCEPTED 
Other possible test case:
Output:
Unsure
Spam
Ham
Many thanks for your posts.


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
==
Unsure
Spam
Ham