-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBOGGLE.cs
63 lines (61 loc) · 1.74 KB
/
BOGGLE.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AlgoSolution
{
class BOGGLE
{
static int Point(string word)
{
int len = word.Length;
if (len <= 4)
return 1;
if (len == 5)
return 2;
if (len == 6)
return 3;
if (len == 7)
return 5;
return 11;
}
static void Main()
{
Run();
Console.ReadLine();
}
static void Run()
{
int players = int.Parse(Console.ReadLine());
Dictionary<string, bool> dict = new Dictionary<string, bool>();
Dictionary<int,string[]> data = new Dictionary<int,string[]>();
for (int i = 0; i < players; i++)
{
string[] words = Console.ReadLine().Split();
data.Add(i,words);
for (int j = 0; j < words.Length; j++)
{
if (dict.ContainsKey(words[j]))
dict[words[j]] = true;
else
dict.Add(words[j], false);
}
}
int maxPoint = Int32.MinValue;
int localPoint = 0;
for (int i = 0; i < players; i++)
{
string[] w = data[i];
localPoint = 0;
for (int j = 0; j < w.Length; j++)
{
if (!dict[w[j]])
localPoint += Point(w[j]);
}
if (localPoint > maxPoint)
maxPoint = localPoint;
}
Console.WriteLine(maxPoint);
}
}
}