20250711 baekjoon
This commit is contained in:
parent
efbb3349c0
commit
d8777049a5
30
code_study/Baekjoon/java/_1620.java
Normal file
30
code_study/Baekjoon/java/_1620.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class _1620 {
|
||||||
|
public static void main(String[] args){
|
||||||
|
Scanner sc = new Scanner(System.in);
|
||||||
|
String[] num = sc.nextLine().split(" ");
|
||||||
|
int N = Integer.parseInt(num[0]);
|
||||||
|
int M = Integer.parseInt(num[1]);
|
||||||
|
|
||||||
|
Map<Integer, String> pokeDoc1 = new HashMap<>();
|
||||||
|
Map<String, Integer> pokeDoc2 = new HashMap<>();
|
||||||
|
for(int i=0; i<N; i++){
|
||||||
|
String pokeName = sc.nextLine();
|
||||||
|
pokeDoc1.put(i+1, pokeName);
|
||||||
|
pokeDoc2.put(pokeName, i+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0; i<M; i++) {
|
||||||
|
String quest = sc.nextLine();
|
||||||
|
char ch = quest.charAt(0);
|
||||||
|
if('0' <= ch && ch <= '9'){
|
||||||
|
System.out.println(pokeDoc1.get(Integer.parseInt(quest)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println(pokeDoc2.get(quest));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sc.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
14
code_study/Baekjoon/python/1764.py
Normal file
14
code_study/Baekjoon/python/1764.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import sys
|
||||||
|
N, M = map(int,sys.stdin.readline().rstrip().split())
|
||||||
|
setN = set()
|
||||||
|
setM = set()
|
||||||
|
for _ in range(N):
|
||||||
|
setN.add(sys.stdin.readline().rstrip())
|
||||||
|
for _ in range(M):
|
||||||
|
setM.add(sys.stdin.readline().rstrip())
|
||||||
|
|
||||||
|
result = list(setN&setM)
|
||||||
|
result.sort()
|
||||||
|
sys.stdout.write(str(len(result))+'\n')
|
||||||
|
for s in result:
|
||||||
|
sys.stdout.write(s+'\n')
|
||||||
Loading…
x
Reference in New Issue
Block a user