Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys, math
- # Auto-generated code below aims at helping you parse
- # the standard input according to the problem statement.
- N = int(raw_input()) # Number of elements which make up the association table.
- Q = int(raw_input()) # Number Q of file names to be analyzed.
- mime = {}
- answ = []
- deflt = "UNKNOWN"
- for i in xrange(N):
- # EXT: file extension
- # MT: MIME type.
- EXT, MT = raw_input().split()
- mime[EXT.lower()] = MT
- for i in xrange(Q):
- FNAME = raw_input() # One file name per line.
- to_srch = FNAME.split('.')
- print >> sys.stderr, "to s: {0}".format(to_srch)
- if len(to_srch) > 1:
- answ.append(mime.get(to_srch[-1].lower(), deflt))
- else:
- answ.append(deflt)
- # Write an action using print
- # To debug: print >> sys.stderr, "Debug messages..."
- for row in answ:
- print row # For each of the Q filenames, display on a line the corresponding MIME type. If there is no corresponding type, then display UNKNOWN.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement