https://www.acmicpc.net/problem/9555코드import sysinput = sys.stdin.readlinedx = [-1, -1, 0, 1, 1, 1, 0, -1]dy = [0, 1, 1, 1, 0, -1, -1, -1]for _ in range(int(input())): n, m = map(int, input().split()) teams = [list(map(int, input().split())) for _ in range(n)] answer = set() for x in range(n): for y in range(m): if teams[x][y] == -1 or teams[x][y] in answer: ..
문제풀이/구현
https://www.acmicpc.net/problem/11387코드def combat_power(info): attack, power, critical, critical_damage, speed = info result = attack result *= (100 + power) result *= (100*(100 - min(100, critical)) + min(100, critical)*critical_damage) result *= (100 + speed) return resultinfos = [list(map(int, input().split())) for _ in range(4)]now_cri = combat_power(infos[0])..
https://www.acmicpc.net/problem/11067코드import sysinput = sys.stdin.readlinefor _ in range(int(input())): n = int(input()) cafes = {} for _ in range(n): x, y = map(int, input().split()) if x not in cafes: cafes[x] = [] cafes[x].append(y) prev_y = 0 counted_cafe = [] for x, y_list in sorted(cafes.items()): y_list.sort() if y_list[0] !..
https://www.acmicpc.net/problem/15905코드n = int(input())arr = [list(map(int, input().split())) for _ in range(n)]arr.sort(key=lambda x: (-x[0], x[1]))answer = 0for i in range(5, n): if arr[i][0] == arr[4][0]: answer += 1 else: breakprint(answer) 6위부터의 사람들 중 5위와 맞힌 문제 수가 같은 사람이 몇 명인지를 구하면 된다. 그러기 위해 우선 정렬을 사용하여 순위를 매긴다.arr.sort(key=lambda x: (-x[0], x[1]))이렇게 하면 맞힌 문제 수 내림차순, 맞..
https://leetcode.com/problems/word-subsets/description/코드from collections import defaultdictdef get_alphabet_dict(word): temp = defaultdict(int) for i in range(len(word)): temp[word[i]] += 1 return tempdef wordSubsets(words1, words2): alphabet_dict = dict() for w2 in words2: temp = get_alphabet_dict(w2) for k, v in temp.items(): if k not in alphabet..