๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ 479

๐ŸŸฉ [๋ฐฑ์ค€] [Python] 11060๋ฒˆ_์ ํ”„ ์ ํ”„

๋ฌธ์ œ https://www.acmicpc.net/problem/11060 11060๋ฒˆ: ์ ํ”„ ์ ํ”„ ์žฌํ™˜์ด๊ฐ€ 1×N ํฌ๊ธฐ์˜ ๋ฏธ๋กœ์— ๊ฐ‡ํ˜€์žˆ๋‹ค. ๋ฏธ๋กœ๋Š” 1×1 ํฌ๊ธฐ์˜ ์นธ์œผ๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๊ณ , ๊ฐ ์นธ์—๋Š” ์ •์ˆ˜๊ฐ€ ํ•˜๋‚˜ ์“ฐ์—ฌ ์žˆ๋‹ค. i๋ฒˆ์งธ ์นธ์— ์“ฐ์—ฌ ์žˆ๋Š” ์ˆ˜๋ฅผ Ai๋ผ๊ณ  ํ–ˆ์„ ๋•Œ, ์žฌํ™˜์ด๋Š” Ai์ดํ•˜๋งŒํผ ์˜ค๋ฅธ์ชฝ์œผ๋กœ www.acmicpc.net ํ’€์ด # ๋ฐฑ์ค€ 11060๋ฒˆ ๋ฌธ์ œ - ์ ํ”„ ์ ํ”„ import collections n=int(input()) arr=list(map(int, input().split())) dp=[1e9 for _ in range(n)] def bfs(): q=collections.deque() q.append((0, 0)) dp[0]=0 while q: cur, cnt=q.popleft() if ..

๐ŸŸฉ [๋ฐฑ์ค€] [Python] 2210๋ฒˆ_์ˆซ์žํŒ ์ ํ”„

๋ฌธ์ œ https://www.acmicpc.net/problem/2210 2210๋ฒˆ: ์ˆซ์žํŒ ์ ํ”„ 111111, 111112, 111121, 111211, 111212, 112111, 112121, 121111, 121112, 121211, 121212, 211111, 211121, 212111, 212121 ์ด ๊ฐ€๋Šฅํ•œ ๊ฒฝ์šฐ๋“ค์ด๋‹ค. www.acmicpc.net ํ’€์ด # ๋ฐฑ์ค€ 2210๋ฒˆ ๋ฌธ์ œ - ์ˆซ์žํŒ ์ ํ”„ from collections import deque dx, dy = [0,0,-1,1], [1,-1,0,0] graph = [list(map(str, input().split(' '))) for _ in range(5)] def dfs(x, y, number): if len(number) == 6: i..

๐ŸŸฉ [๋ฐฑ์ค€] [Python] 5567๋ฒˆ_๊ฒฐํ˜ผ์‹

๋ฌธ์ œ https://www.acmicpc.net/problem/5567 5567๋ฒˆ: ๊ฒฐํ˜ผ์‹ ์˜ˆ์ œ 1์˜ ๊ฒฝ์šฐ 2์™€ 3์€ ์ƒ๊ทผ์ด์˜ ์นœ๊ตฌ์ด๋‹ค. ๋˜, 3๊ณผ 4๋Š” ์นœ๊ตฌ์ด๊ธฐ ๋•Œ๋ฌธ์—, 4๋Š” ์ƒ๊ทผ์ด์˜ ์นœ๊ตฌ์˜ ์นœ๊ตฌ์ด๋‹ค. 5์™€ 6์€ ์นœ๊ตฌ๋„ ์•„๋‹ˆ๊ณ , ์นœ๊ตฌ์˜ ์นœ๊ตฌ๋„ ์•„๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ 2, 3, 4 3๋ช…์˜ ์นœ๊ตฌ๋ฅผ ๊ฒฐํ˜ผ์‹์— ์ดˆ๋Œ€ www.acmicpc.net ํ’€์ด # ๋ฐฑ์ค€ 5567๋ฒˆ ๋ฌธ์ œ - ๊ฒฐํ˜ผ์‹ from sys import stdin n = int(stdin.readline().strip()) graph = [[] for _ in range(n + 1)] visited = [0] * (n + 1) for _ in range(int(stdin.readline().strip())): x, y = map(int, stdin.readl..

๐ŸŸฉ [๋ฐฑ์ค€] [Python] 11055๋ฒˆ_๊ฐ€์žฅ ํฐ ์ฆ๊ฐ€ ๋ถ€๋ถ„ ์ˆ˜์—ด

๋ฌธ์ œ https://www.acmicpc.net/problem/11055 11055๋ฒˆ: ๊ฐ€์žฅ ํฐ ์ฆ๊ฐ€ ๋ถ€๋ถ„ ์ˆ˜์—ด ์ˆ˜์—ด A๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, ๊ทธ ์ˆ˜์—ด์˜ ์ฆ๊ฐ€ ๋ถ€๋ถ„ ์ˆ˜์—ด ์ค‘์—์„œ ํ•ฉ์ด ๊ฐ€์žฅ ํฐ ๊ฒƒ์„ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ์ˆ˜์—ด A = {1, 100, 2, 50, 60, 3, 5, 6, 7, 8} ์ธ ๊ฒฝ์šฐ์— ํ•ฉ์ด ๊ฐ€์žฅ ํฐ ์ฆ๊ฐ€ ๋ถ€๋ถ„ ์ˆ˜ www.acmicpc.net ํ’€์ด # ๋ฐฑ์ค€ 11055๋ฒˆ ๋ฌธ์ œ - ๊ฐ€์žฅ ํฐ ์ฆ๊ฐ€ ๋ถ€๋ถ„ ์ˆ˜์—ด n = int(input()) numbers = list(map(int, input().split())) dp = numbers[:] dp[0] = numbers[0] for i in range(1, n): for j in range(i): if numbers[j] < nu..

๐ŸŸฉ [๋ฐฑ์ค€] [Python] 17413๋ฒˆ_๋‹จ์–ด ๋’ค์ง‘๊ธฐ 2

๋ฌธ์ œ https://www.acmicpc.net/problem/17413 17413๋ฒˆ: ๋‹จ์–ด ๋’ค์ง‘๊ธฐ 2 ๋ฌธ์ž์—ด S๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, ์ด ๋ฌธ์ž์—ด์—์„œ ๋‹จ์–ด๋งŒ ๋’ค์ง‘์œผ๋ ค๊ณ  ํ•œ๋‹ค. ๋จผ์ €, ๋ฌธ์ž์—ด S๋Š” ์•„๋ž˜์™€๊ณผ ๊ฐ™์€ ๊ทœ์น™์„ ์ง€ํ‚จ๋‹ค. ์•ŒํŒŒ๋ฒณ ์†Œ๋ฌธ์ž('a'-'z'), ์ˆซ์ž('0'-'9'), ๊ณต๋ฐฑ(' '), ํŠน์ˆ˜ ๋ฌธ์ž('')๋กœ๋งŒ ์ด๋ฃจ์–ด์ ธ www.acmicpc.net ํ’€์ด # ๋ฐฑ์ค€ 17413๋ฒˆ ๋ฌธ์ œ - ๋‹จ์–ด ๋’ค์ง‘๊ธฐ 2 s = list(input()) tag = False word = '' result = '' for i in s: if tag == False: if i == '': tag = False result = result + word word = '' print(result + word)

๐ŸŸฉ [๋ฐฑ์ค€] [Python] 10844๋ฒˆ_์‰ฌ์šด ๊ณ„๋‹จ ์ˆ˜

๋ฌธ์ œ https://www.acmicpc.net/problem/10844 10844๋ฒˆ: ์‰ฌ์šด ๊ณ„๋‹จ ์ˆ˜ ์ฒซ์งธ ์ค„์— ์ •๋‹ต์„ 1,000,000,000์œผ๋กœ ๋‚˜๋ˆˆ ๋‚˜๋จธ์ง€๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. www.acmicpc.net ํ’€์ด # ๋ฐฑ์ค€ 10844๋ฒˆ ๋ฌธ์ œ - ์‰ฌ์šด ๊ณ„๋‹จ ์ˆ˜ n = int(input()) dp = [[0]*10 for _ in range(n+1)] for i in range(1, 10): dp[1][i] = 1 value = 1000000000 for i in range(2, n+1): for j in range(10): if j == 0: dp[i][j] = dp[i-1][1] elif j == 9: dp[i][j] = dp[i-1][8] else: dp[i][j] = dp[i-1][j-1] + dp[i-1]..

๐ŸŸฉ [๋ฐฑ์ค€] [Python] 9205๋ฒˆ_๋งฅ์ฃผ ๋งˆ์‹œ๋ฉด์„œ ๊ฑธ์–ด๊ฐ€๊ธฐ

๋ฌธ์ œ https://www.acmicpc.net/problem/9205 9205๋ฒˆ: ๋งฅ์ฃผ ๋งˆ์‹œ๋ฉด์„œ ๊ฑธ์–ด๊ฐ€๊ธฐ ์†ก๋„์— ์‚ฌ๋Š” ์ƒ๊ทผ์ด์™€ ์นœ๊ตฌ๋“ค์€ ์†ก๋„์—์„œ ์—ด๋ฆฌ๋Š” ํŽœํƒ€ํฌํŠธ ๋ฝ ํŽ˜์Šคํ‹ฐ๋ฒŒ์— ๊ฐ€๋ ค๊ณ  ํ•œ๋‹ค. ์˜ฌํ•ด๋Š” ๋งฅ์ฃผ๋ฅผ ๋งˆ์‹œ๋ฉด์„œ ๊ฑธ์–ด๊ฐ€๊ธฐ๋กœ ํ–ˆ๋‹ค. ์ถœ๋ฐœ์€ ์ƒ๊ทผ์ด๋„ค ์ง‘์—์„œ ํ•˜๊ณ , ๋งฅ์ฃผ ํ•œ ๋ฐ•์Šค๋ฅผ ๋“ค๊ณ  ์ถœ๋ฐœํ•œ๋‹ค. www.acmicpc.net ํ’€์ด # ๋ฐฑ์ค€ 9205๋ฒˆ ๋ฌธ์ œ - ๋งฅ์ฃผ ๋งˆ์‹œ๋ฉด์„œ ๊ฑธ์–ด๊ฐ€๊ธฐ import sys from collections import deque input = sys.stdin.readline def bfs(): q = deque() q.append([home[0], home[1]]) while q: x, y = q.popleft() if abs(x-festival[0]) + abs(y-festiva..