-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodeC#
57 lines (50 loc) · 1.76 KB
/
codeC#
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
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
class Solution
{
static void Main(string[] args)
{
int N = int.Parse(Console.ReadLine()); // Number of elements which make up the association table.
int Q = int.Parse(Console.ReadLine()); // Number Q of file names to be analyzed.
Dictionary <string,string> extDict = new Dictionary <string,string>();
string[] ext = new string [Q];
for (int i = 0; i < N; i++)
{
string[] inputs = Console.ReadLine().Split(' ');
extDict.Add("."+ inputs[0].ToUpper(), inputs[1]);
}
for (int i = 0; i < Q; i++)
{
string FNAME = Console.ReadLine(); // One file name per line.
ext[i] = Path.GetExtension(FNAME).ToUpper();
Console.WriteLine(extDict.ContainsKey(ext[i])? extDict[ext[i]] : "UNKNOWN");
}
/*foreach(string extension in ext)
{
if (extension == null)
{
Console.WriteLine("UNKNOWN");
continue;
}
if(extDict.ContainsKey(extension))
{
Console.WriteLine(extDict[extension]);
}
else
{
Console.WriteLine("UNKNOWN");
}
}*/
// Write an action using Console.WriteLine()
// To debug: Console.Error.WriteLine("Debug messages...");
// For each of the Q filenames, display on a line the corresponding MIME type. If there is no corresponding type, then display UNKNOWN.
}
}