
解答例コードがある問題なので、アップする意味はあまりないのですが自分用の覚え書きに
import java.util.*;
public class Main {
public static void main(String[] args) {
// 自分の得意な言語で
// Let's チャレンジ!!
/*
1 行目には A グループ、 B グループ、 C グループのそれぞれの人数 p , q , r が半角スペース区切りで与えられます。
2 行目から (p + 1) 行目までは A グループの人の番号とその人が仕事を頼む B グループの人の番号 i_a, j_a (1 ≤ a ≤ p) が半角スペース区切りで、 (p + 2) 行目から (p + q + 2) 行目までは
B グループの人の番号とその人が仕事を頼む C グループの人の番号 j’_b , k_b (1 ≤ b ≤ q) が半角スペース区切りで与えられます。
*/
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
HashMap<Integer, Integer> hoges_a = new HashMap<>();
HashMap<Integer, Integer> hoges_b = new HashMap<>();
for(int i=0; i<a; i++){
int up = sc.nextInt();
int down = sc.nextInt();
hoges_a.put(up,down);
}
for(int i=0; i<b; i++){
int up = sc.nextInt();
int down = sc.nextInt();
hoges_b.put(up,down);
}
for(int i=1; i<=a; i++){
int search_b = hoges_a.get(i);
int search_c = hoges_b.get(search_b);
System.out.println(i+" "+search_c);
}
}
}

https://paiza.jp/works/mondai/c_rank_level_up_problems/c_rank_dictionary_boss
paiza問題集
0