문제풀이/구현

https://www.acmicpc.net/problem/1041코드from itertools import combinationsn = int(input())dice = list(map(int, input().split()))one_min = min(dice)two_min = int(1e9)for comb in combinations(range(6), 2): if sum(comb) == 5: continue total = dice[comb[0]]+dice[comb[1]] if total  5개의 면에서 어느 부분이 1면만 노출될지, 2면이 노출될지, 3면이 노출될지 생각해보면 다음과 같다. 빨간색으로 표시된 모서리는 3면, 민트색 표시는 2면, 그 외에는 1면이 노출되게 된다..
https://leetcode.com/problems/count-and-say/description/코드def countAndSay(n): string = "1" for _ in range(n-1): new_string = "" cnt = 1 prev = string[0] for s in string[1:]: if s == prev: cnt += 1 else: new_string += (str(cnt)+prev) prev = s cnt = 1 new_string += (str(cnt)+p..
https://leetcode.com/problems/rotate-image/description/코드from copy import deepcopyclass Solution: def rotate(self, matrix: List[List[int]]) -> None: n = len(matrix) max_depth = n//2 for depth in range(max_depth+1): length = n-depth*2-1 # 위쪽 저장 top = deepcopy(matrix[depth][depth+1:n-depth]) # 왼 -> 위 for i in range(leng..
https://www.acmicpc.net/problem/8972코드r, c = map(int, input().split())map_data = [list(input()) for _ in range(r)]movings = list(map(int, list(input())))dirs = [(0, 0), (1, -1), (1, 0), (1, 1), (0, -1), (0, 0), (0, 1), (-1, -1), (-1, 0), (-1, 1)]def manhatan_distance(x1, y1, x2, y2): return abs(x1-x2)+abs(y1-y2)def solution(r, c, map_data, movings): js = [] crazys = [] for i i..
https://softeer.ai/practice/11002코드import sysinput = sys.stdin.readlinen, m = map(int, input().split())cptis = dict()for _ in range(n): input_cpti = int(input(), 2) if input_cpti in cptis: cptis[input_cpti] += 1 else: cptis[input_cpti] = 1answer = 0for num in cptis.keys(): answer += (cptis[num]*(cptis[num]-1))//2 # 1개 다른 사람 세기 for i in range(m): new_num = n..
딜레이레이
'문제풀이/구현' 카테고리의 글 목록 (2 Page)