fork download
  1. import java.io.*;
  2. import java.util.*;
  3. public class Main
  4. {
  5. public static void main(String []args)throws IOException{
  6. // System.out.println("Enter Number of Media Type Association (N): ");
  7. int n=Integer.parseInt(x.readLine());
  8. // System.out.println("Enter Number of File Names (Q): ");
  9. int q=Integer.parseInt(x.readLine());
  10. HashMap<String,String> a=new HashMap<String,String>();
  11. for(int i=1;i<=n;i++){
  12. // System.out.println("Media Type "+i+": ");
  13. String parts[]=x.readLine().split(" ");
  14. a.put(parts[0],parts[1]);
  15. }
  16. for(int i=1;i<=q;i++){
  17.  
  18. //System.out.println("File Name "+i+": ");
  19. String w=x.readLine();
  20. String h=w.substring(w.lastIndexOf('.')+1,w.length());
  21. if(a.containsKey(h)) System.out.println(a.get(h));
  22. else System.out.println("unknown");
  23. }
  24. }
  25. }
Success #stdin #stdout 0.06s 380160KB
stdin
5
6
html text
htm text1
png img
svg image
txt text3
index.html
this.file.has.lots.of.dots.txt
nodotsatall
virus.exe
dont.let.the.png.fool.you
case.matters.TXT
stdout
text
text3
unknown
unknown
unknown
unknown