Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class RoutingHashJava {
- public static void main (String [] args) {
- Scanner sc = new Scanner (System.in);
- HashMap <String,String> map = new HashMap <> ();
- int N = Integer.parseInt(sc.nextLine());
- for(int i=0; i<N; i++)
- map.put(sc.nextLine(),sc.nextLine());
- N = Integer.parseInt(sc.nextLine());
- for(int i=0; i<N; i++) {
- String tester = sc.nextLine();
- String [] parts = sc.nextLine().split("\\.");
- boolean itHas = false;
- if(!map.containsKey(tester))
- System.out.println("ne postoi");
- else {
- String [] temps = map.get(tester).split("\\,");
- for(int j=0; j<temps.length; j++) {
- String [] address = temps[j].split("\\.");
- if(address[0].equals(parts[0]) && address[1].equals(parts[1]) && address[2].equals(parts[2]))
- itHas = true;
- }
- if(itHas)
- System.out.println("postoi");
- else
- System.out.println("ne postoi");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment