BOGGLE - Boggle Scoring

In Boggle, you win points for words you find on the board which no other player finds. If another player finds the same word as you, neither player gets points for that word.

For words of 4 or fewer letters, 1 point is awarded. 5-letter words are worth 2 points, 6-letter words are worth 3 points, 7-letter words are worth 5 points, and words longer than 7 letters are worth 11 points.

Given the set of words that some boggle players found, determine the score of the winner.

Input

The first line is the number of players (at most 100).
Each subsequent line is the space-separated list of no more than than 50 words each no more than 50 characters (ASCII 33-126) that player found.

Output

The score of the winning player.

Sample

Input
2
one two three
two three four

Output
1
Input
3
good dual strange stranger would
dual would duality dregs gnaw
dual gnaw draw would student

Output
17
Input
2
grid grades dread bread thread threads
grid grids grade brood broods thread threads

Output
9

Added by:Ben Dilts
Date:2012-10-12
Time limit:9.479s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64

hide comments
2016-04-18 19:27:04
Can someone please explain to me why this problem has a time limit of 9.479 seconds ? My pure brute force python solution runs in 0.02 seconds and it is very easy to reach 0.00 seconds.
2015-08-13 09:05:13 Baojun Wang
small input data.
2015-02-21 18:02:21 ashish kumar
AC in one go
2014-09-30 14:19:54 Archit Jain
easy one
2014-06-10 19:39:14 salman
some testcases plz ...
2014-05-22 15:07:54 monera
at last done .. learnt something new :D
2014-04-30 19:43:56 Kaushik
STL rocks ;)
2014-03-16 22:03:45 NISHANT RAJ
AC in first attempt using c++ inbuilt function..
2014-03-16 04:06:40 kelaseek
dude. why nzec error?pls pls check;id:11255518
ac with array size 100 . it's greater than 50

Last edit: 2014-03-16 04:20:23
2014-02-26 21:12:19 jobanpreet singh
please provide some test cases.
I have tried many on ideone and i get correct answer for each case.
But getting WA here.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.