본문 바로가기
✨ 서울대생이 면접 떨어지고 6개월간 삽질하며 정리한 'CS 정리 노트', 지금 무료로 풀립니다!

전체 글 목록591

[삼성 SW 역량테스트] 1247. 최적 경로 / D5 https://swexpertacademy.com/main/code/problem/problemDetail.do SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com tc = int(input()) def dist(p1, p2): return abs(p1[0]-p2[0]) + abs(p1[1]-p2[1]) def dfs(count, order, visited): global answer if count == n: total = dist(company, clients[order[0]]) for i in range(len(order)-1): total += dist(clients[order[i]], clients[ord.. 2022. 3. 10.
[비트마스킹/ 파이썬 ] 백준 1062번 : 가르침 / 골드 4 https://www.acmicpc.net/problem/1062 import sys sys.setrecursionlimit(10 ** 5) n, k = map(int, input().split()) if k < 5: print(0) quit() must = 0 for alpha in 'antic': order = ord(alpha) - ord('a') must |= 1 2022. 3. 9.
[비트마스킹 / 파이썬] 백준 9997번: 폰트 / 골드 2 https://www.acmicpc.net/problem/9997 9997번: 폰트 첫째 줄에 단어의 개수 N (1 ≤ N ≤ 25)가 주어진다. 다음 N개 줄에는 사전에 포함되어있는 단어가 주어진다. 단어의 길이는 100을 넘지 않으며, 중복되는 단어는 주어지지 않는다. www.acmicpc.net import sys sys.setrecursionlimit(10**5) n = int(input()) lst = [] for _ in range(n): word = input() b = 0 for alpha in word: order = ord(alpha)-ord('a') b |= 1 2022. 3. 9.
[재귀 / 파이썬] 백준 1030번 : 프렉탈 평면*** / 골드 3 https://www.acmicpc.net/problem/1030 1030번: 프렉탈 평면 첫째 줄에 7개의 정수 s, N, K, R1, R2, C1, C2가 주어진다. www.acmicpc.net s, n, k, x1, x2, y1, y2 = map(int, input().split()) m = (n - k) // 2 def check(x, y, t): if t == 0: return 0 nn = n**(t-1) nx = x // nn ny = y // nn if m 2022. 3. 8.
[재귀 / 파이썬] 백준 10993번 : 별 찍기 -18 / 골드 4 https://www.acmicpc.net/problem/10993 10993번: 별 찍기 - 18 예제를 보고 규칙을 유추한 뒤에 별을 찍어 보세요. www.acmicpc.net n = int(input()) def star(depth): if depth == 1: return ['*'] m = 2**(depth+1)-3 table = [[' ' for _ in range(m)] for _ in range(m)] k = 2**depth-3 shift = 2**(depth-1) if depth % 2 == 0: for i in range(m): table[0][i] = '*' j = 0 for i in range(0, m, 2): table[i][j] = '*' j += 1 j -= 1 for i in .. 2022. 3. 7.
[재귀 / 파이썬 ] 백준 1662번 : 압축 / 골드 5 https://www.acmicpc.net/problem/1662 1662번: 압축 압축되지 않은 문자열 S가 주어졌을 때, 이 문자열중 어떤 부분 문자열은 K(Q)와 같이 압축 할 수 있다. K는 한자리 정수이고, Q는 0자리 이상의 문자열이다. 이 Q라는 문자열이 K번 반복된다는 뜻이 www.acmicpc.net import collections s = collections.deque([x for x in input()]) def recursion(s): if len(s) == 1: return 1 temp = 0 while s: cur = s.popleft() if not s: temp += 1 break if cur.isnumeric() and s[0] != '(': temp += 1 elif c.. 2022. 3. 7.