본문 바로가기
반응형

hash5

[BOJ][Python]9375번 풀이 https://www.acmicpc.net/problem/9375 9375번: 패션왕 신해빈 첫 번째 테스트 케이스는 headgear에 해당하는 의상이 hat, turban이며 eyewear에 해당하는 의상이 sunglasses이므로 (hat), (turban), (sunglasses), (hat,sunglasses), (turban,sunglasses)로 총 5가지 이다. www.acmicpc.net t = int(input()) for _ in range(t): n = int(input()) cl = [input().split() for _ in range(n)] c = {i[1]:[] for i in cl} ans_l = [] for i in cl: c[i[1]].append(i[0]) for i .. 2022. 6. 9.
[BOJ][Python]17219번 풀이 https://www.acmicpc.net/problem/17219 17219번: 비밀번호 찾기 첫째 줄에 저장된 사이트 주소의 수 N(1 ≤ N ≤ 100,000)과 비밀번호를 찾으려는 사이트 주소의 수 M(1 ≤ M ≤ 100,000)이 주어진다. 두번째 줄부터 N개의 줄에 걸쳐 각 줄에 사이트 주소와 비밀번 www.acmicpc.net import sys input = sys.stdin.readline n,m = map(int, input().split()) d = {} for _ in range(n): a,b = map(str, input().rstrip().split()) d[a] = b for _ in range(m): print(d[input().rstrip()]) 전혀 다를 것 없는 해시 .. 2022. 6. 4.
[BOJ][Python]1620번 풀이 https://www.acmicpc.net/problem/1620 1620번: 나는야 포켓몬 마스터 이다솜 첫째 줄에는 도감에 수록되어 있는 포켓몬의 개수 N이랑 내가 맞춰야 하는 문제의 개수 M이 주어져. N과 M은 1보다 크거나 같고, 100,000보다 작거나 같은 자연수인데, 자연수가 뭔지는 알지? 모르면 www.acmicpc.net import sys input = sys.stdin.readline n,m = map(int, input().split()) d = {i:input().rstrip() for i in range(1,n+1)} t = dict(map(reversed, d.items())) for _ in range(m): a = input().rstrip() if not a[0].isd.. 2022. 6. 2.
[BOJ][Python]5089번 정리 https://www.acmicpc.net/problem/5089 5089번: Travelling Salesman Output consists of a single line for each week. It contains the word Week, followed by a space, followed by the week number, the first week being 1, followed by a space, followed by the actual number of towns to be visited, duplicates having been removed. www.acmicpc.net cnt = 0 while 1: cnt += 1 n = int(input()) if n == 0: break t .. 2022. 6. 1.
[BOJ][Python]18679번 풀이 https://www.acmicpc.net/problem/18679 18679번: Banana The first line of input will contain a single integer N, the number of words in the dictionary (1 ≤ N ≤ 100). The following N lines will each contain a sentence of the format x = y where x is an English word and y is a Minionese word. The next line wil www.acmicpc.net n = int(input()) dict = {} for _ in range(n): a,b = input().split(' = ') dic.. 2022. 5. 31.
반응형