분류 전체보기

n, m = map(int, input().split()) no_listen, no_see = set(), set() for i in range(n): no_listen.add(input()) for j in range(m): no_see.add(input()) result = sorted(no_listen & no_see) print(len(result)) for name in result: print(name) https://www.acmicpc.net/problem/1764 1764번: 듣보잡 첫째 줄에 듣도 못한 사람의 수 N, 보도 못한 사람의 수 M이 주어진다. 이어서 둘째 줄부터 N개의 줄에 걸쳐 듣도 못한 사람의 이름과, N+2째 줄부터 보도 못한 사람의 이름이 순서대로 주어진다. www...
n = int(input()) n_ls = [] for i in range(n): n_ls.append(input()) m = int(input()) m_ls = [] for i in range(m): m_ls.append(input()) idx = n_ls.index('?') prev = idx-1 next = idx+1 for word in m_ls: if word in n_ls: continue # 기존에 사용한 단어인경우 if idx == 0: # 물음표가 첫번째일때 if len(n_ls) == 1: print(word) elif word[len(word)-1] == n_ls[next][0]: print(word) elif idx == len(n_ls) - 1: # 물음표가 마지막일때 if wor..
n, b = input().split() print(int(n, int(b))) https://www.acmicpc.net/problem/2745
print(''.join(map(lambda s: s[0], input().split('-')))) https://www.acmicpc.net/problem/2902
N, M = map(int, input().split()) num_list = sorted(list(map(int, input().split()))) s = [] visited = [False] * N def dfs(): if len(s) == M: print(' '.join((map(str, s)))) return remember_me = 0 for i in range(N): if not visited[i] and remember_me != num_list[i]: visited[i] = True s.append(num_list[i]) remember_me = num_list[i] dfs() s.pop() visited[i] = False dfs() https://www.acmicpc.net/proble..
N = int(input()) ls = set() emoji = 0 for _ in range(N): log = input() if log == 'ENTER': emoji += len(ls) ls.clear() else: ls.add(log) emoji += len(ls) print(emoji) https://www.acmicpc.net/problem/25192 25192번: 인사성 밝은 곰곰이 첫번째 새로운 사람이 들어온 뒤 pjshwa, chansol, chogahui05은 모두 곰곰티콘으로 인사했다. 두번째 새로운 사람이 들어온 뒤 pjshwa와 chansol은 다시 곰곰티콘으로 인사했다. www.acmicpc.net
from itertools import combinations N, M = map(int, input().split()) ls = list(combinations(range(1, N+1), M)) for i in ls: for j in i: print(j) https://www.acmicpc.net/problem/15650
a1, a0 = map(int, input().split()) c = int(input()) n0 = int(input()) if (a1 * n0 + a0)
# 라이브러리를 이용해 순열을 구함 from itertools import permutations N, M = map(int, input().split()) ls = list(permutations(range(1, N + 1), M)) for i in ls: for j in i: print(j, end=' ') # dfs(깊이 우선 탐색) N, M = map(int, input().split()) s = [] # 수열이 담길 리스트 visited = [False] * (N+1) # 중복제거를 위한 체크용 리스트 def dfs(): if len(s) == M: print(' '.join((map(str, s)))) return for i in range(1, N+1): if visited[i]: conti..
# 이진탐색 사용해서 풀기 N = int(input()) # 숫자 카드 개수 cards = sorted(list(map(int, input().split()))) # 숫자 카드 리스트 M = int(input()) # 찾아야할 숫자 개수 nums = list(map(int, input().split())) # 찾아야할 숫자 리스트 num_dict = {} for n in cards: # 갖고 있는 카드들을 딕셔너리에 추가. 리스트에 있는 개수만큼 value를 더한다. if n in num_dict: num_dict[n] += 1 else: num_dict[n] = 1 # 이진탐색 함수 def binary(target, cards, start, end): if start > end: # 시작값이 끝값보다 ..
해리Harry
'분류 전체보기' 카테고리의 글 목록 (10 Page)