fork download
  1. import java.util.*;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6. int n = sc.nextInt();
  7. sc.nextLine();
  8. Map<String, String> mp = new HashMap<>();
  9. while((n--) > 0){
  10. String msv = sc.nextLine();
  11. String ten = sc.nextLine();
  12. mp.put(msv, ten);
  13. }
  14. int q = sc.nextInt();
  15. sc.nextLine();
  16. while((q--) > 0){
  17. String msv = sc.nextLine();
  18. if(mp.containsKey(msv)){
  19. System.out.println(mp.get(msv));
  20. } else {
  21. System.out.println("NOT FOUND");
  22. }
  23. }
  24.  
  25. }
  26. }
  27.  
Success #stdin #stdout 0.13s 54524KB
stdin
3
SV001
Hoang Van Nam
SV002
Ngo Gia Long
SV005
Phuong The Ngoc
2
SV005
SV003
stdout
Phuong The Ngoc
NOT FOUND