fork download
  1. import java.util.*;
  2. import java.io.*;
  3. class test
  4. {
  5. public static void main(String[] args) throws IOException
  6. {
  7.  
  8.  
  9.  
  10. String input[]=br.readLine().split(" ");
  11.  
  12. int N=Integer.parseInt(input[0]);
  13. int k=Integer.parseInt(input[1]);
  14. int L=Integer.parseInt(input[2]);
  15. int Q=Integer.parseInt(input[3]);
  16.  
  17. String [] name=new String[N];
  18. int num[]=new int[N];
  19.  
  20. for(int i=0;i<N;i++)
  21. {
  22. String temp="";
  23. String inputs[]=br.readLine().split(" ");
  24. name[i]=inputs[0];
  25. if(k<2)
  26. temp+=inputs[1];
  27. else if(k<3)
  28. temp+=inputs[1]+inputs[2];
  29. else if(k<4)
  30. temp+=inputs[1]+inputs[2]+inputs[3];
  31. else if(k<5)
  32. temp+=inputs[1]+inputs[2]+inputs[3]+inputs[4];
  33. else if(k<6)
  34. temp+=inputs[1]+inputs[2]+inputs[3]+inputs[4]+inputs[5];
  35.  
  36. num[i]=Integer.parseInt(temp);
  37. }
  38.  
  39. for(int j=0;j<Q;j++)
  40. {String temps="";
  41. String inputs[]=br.readLine().split(" ");
  42. if(k<2)
  43. temps+=inputs[0];
  44. else if(k<3)
  45. temps+=inputs[0]+inputs[1];
  46. else if(k<4)
  47. temps+=inputs[0]+inputs[1]+inputs[2];
  48. else if(k<5)
  49. temps+=inputs[0]+inputs[1]+inputs[2]+inputs[3];
  50. else if(k<6)
  51. temps+=inputs[0]+inputs[1]+inputs[2]+inputs[3]+inputs[4];
  52.  
  53. int number=Integer.parseInt(temps);
  54.  
  55. for(int i=0;i<N;i++)
  56. {
  57. if(number==num[i])
  58. {
  59. System.out.println(name[i]);
  60. break;
  61. }
  62.  
  63.  
  64. if(i==N-1 && number!=num[i])
  65. System.out.println("You cant fool me :P");
  66. }
  67.  
  68. }
  69. }
  70.  
  71. }
  72.  
Success #stdin #stdout 0.06s 380160KB
stdin
5 3 9 5
baryonyx 5 1 7
jobaria 1 2 3
oviraptor 9 7 1
troodon 6 9 5
minmi 7 4 5
9 7 1
1 2 3
5 8 8
1 2 3
7 4 5
stdout
oviraptor
jobaria
You cant fool me :P
jobaria
minmi