Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. import sys, math
  2.  
  3. # Auto-generated code below aims at helping you parse
  4. # the standard input according to the problem statement.
  5.  
  6. N = int(raw_input()) # Number of elements which make up the association table.
  7. Q = int(raw_input()) # Number Q of file names to be analyzed.
  8.  
  9. mime = {}
  10. answ = []
  11. deflt = "UNKNOWN"
  12.  
  13. for i in xrange(N):
  14.     # EXT: file extension
  15.     # MT: MIME type.
  16.     EXT, MT = raw_input().split()
  17.     mime[EXT.lower()] = MT
  18.    
  19. for i in xrange(Q):
  20.     FNAME = raw_input() # One file name per line.
  21.    
  22.     to_srch = FNAME.split('.')
  23.     print >> sys.stderr, "to s: {0}".format(to_srch)
  24.    
  25.     if len(to_srch) > 1:
  26.         answ.append(mime.get(to_srch[-1].lower(), deflt))
  27.     else:
  28.         answ.append(deflt)
  29.    
  30.  
  31. # Write an action using print
  32. # To debug: print >> sys.stderr, "Debug messages..."
  33.  
  34. for row in answ:
  35.     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