fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n,q,a,pos,y;
  7. string s1[101],s2[101],s,x;
  8. cin >> n >> q;
  9. for(int i=0; i<n; i++)
  10. {
  11. cin >> s1[i] >> s2[i];
  12. }
  13. for(int i=0; i<q; i++)
  14. {
  15. x = "";
  16. pos = y = 0;
  17. a = 0;
  18. cin >> s;
  19. for(int i=0; i<s.length(); i++)
  20. {
  21. if(s[i] == '.')
  22. {
  23. pos = i;
  24. }
  25. }
  26. if(pos == 0)
  27. {
  28. cout << "unknown" << endl;
  29. }
  30.  
  31. else
  32. {
  33. for(int i=pos+1; i<s.length(); i++)
  34. {
  35. x += s[i];
  36. }
  37. for(int j=0; j<n; j++)
  38. {
  39. a = 0;
  40. y = 0;
  41. for(int i=0; i<x.length(); i++)
  42. {
  43. if(x[i] == s1[j][i])
  44. {
  45. a++;
  46. }
  47. }
  48. if(a == s1[j].length() && a == x.length())
  49. {
  50. cout << s2[j] << endl;
  51. y++;
  52. break;
  53. }
  54. }
  55. if(y == 0)
  56. cout << "unknown" << endl;
  57. }
  58. }
  59. }
Success #stdin #stdout 0s 4520KB
stdin
5 6
html text/html
htm text/html
png image/png
svg image/svg+xml
txt text/plain
index.html
this.file.has.lots.of.dots.txt
nodotsatall
virus.exe
dont.let.the.png.fool.you
case.matters.TXT
stdout
text/html
text/plain
unknown
unknown
unknown
unknown