๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์ „์ฒด ๊ธ€

(402)
[Python] ๋ฐฑ์ค€ #1781 - ์ปต๋ผ๋ฉด ๋ฌธ์ œ https://www.acmicpc.net/problem/1781 1781๋ฒˆ: ์ปต๋ผ๋ฉด ์ƒ์šฑ ์กฐ๊ต๋Š” ๋™ํ˜ธ์—๊ฒŒ N๊ฐœ์˜ ๋ฌธ์ œ๋ฅผ ์ฃผ๊ณ ์„œ, ๊ฐ๊ฐ์˜ ๋ฌธ์ œ๋ฅผ ํ’€์—ˆ์„ ๋•Œ ์ปต๋ผ๋ฉด์„ ๋ช‡ ๊ฐœ ์ค„ ๊ฒƒ์ธ์ง€ ์ œ์‹œ ํ•˜์˜€๋‹ค. ํ•˜์ง€๋งŒ ๋™ํ˜ธ์˜ ์ฐŒ๋ฅผ๋“ฏํ•œ ์ž์‹ ๊ฐ์— ์†Œ์‹ฌํ•œ ์ƒ์šฑ ์กฐ๊ต๋Š” ๊ฐ๊ฐ์˜ ๋ฌธ์ œ์— ๋Œ€ํ•ด ๋ฐ๋“œ๋ผ www.acmicpc.net ํ’€์ด import heapq import sys n = int(input()) arr = [] for _ in range(n): tmp = list(map(int,sys.stdin.readline().strip().split())) arr.append(tmp) arr = sorted(arr,key=lambda x:x[0]) # ๋ฐ๋“œ๋ผ์ธ ๊ธฐ์ค€์œผ๋กœ ์˜ค๋ฆ„์ฐจ์ˆœ queue = [] for day,count i..
[Python] ๋ฐฑ์ค€ #9935 - ๋ฌธ์ž์—ด ํญ๋ฐœ ๋ฌธ์ œ https://www.acmicpc.net/problem/9935 9935๋ฒˆ: ๋ฌธ์ž์—ด ํญ๋ฐœ ์ฒซ์งธ ์ค„์— ๋ฌธ์ž์—ด์ด ์ฃผ์–ด์ง„๋‹ค. ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋Š” 1๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™๊ณ , 1,000,000๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™๋‹ค. ๋‘˜์งธ ์ค„์— ํญ๋ฐœ ๋ฌธ์ž์—ด์ด ์ฃผ์–ด์ง„๋‹ค. ๊ธธ์ด๋Š” 1๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™๊ณ , 36๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™๋‹ค. ๋‘ ๋ฌธ์ž์—ด์€ ๋ชจ www.acmicpc.net ํ’€์ด ss = input() m = list(input()) stack = [] for i in range(len(ss)): stack.append(ss[i]) # ์Šคํƒ์— ํ•˜๋‚˜์”ฉ ์ถ”๊ฐ€ if stack[-len(m):] == m: # ์Šคํƒ์˜ ๋งˆ์ง€๋ง‰์ด m ๋ฌธ์ž์—ด๊ณผ ๊ฐ™์œผ๋ฉด del stack[-len(m):] # ์‚ญ์ œ if stack: print("".join(stack)) else:..
[Python] ๋ฐฑ์ค€ #2109 - ์ˆœํšŒ๊ฐ•์—ฐ ๋ฌธ์ œ https://www.acmicpc.net/problem/2109 2109๋ฒˆ: ์ˆœํšŒ๊ฐ•์—ฐ ํ•œ ์ €๋ช…ํ•œ ํ•™์ž์—๊ฒŒ n(0 ≤ n ≤ 10,000)๊ฐœ์˜ ๋Œ€ํ•™์—์„œ ๊ฐ•์—ฐ ์š”์ฒญ์„ ํ•ด ์™”๋‹ค. ๊ฐ ๋Œ€ํ•™์—์„œ๋Š” d(1 ≤ d ≤ 10,000)์ผ ์•ˆ์— ์™€์„œ ๊ฐ•์—ฐ์„ ํ•ด ์ฃผ๋ฉด p(1 ≤ p ≤ 10,000)๋งŒํผ์˜ ๊ฐ•์—ฐ๋ฃŒ๋ฅผ ์ง€๋ถˆํ•˜๊ฒ ๋‹ค๊ณ  ์•Œ๋ ค์™”๋‹ค. www.acmicpc.net ํ’€์ด import sys import heapq n = int(input()) money = 0 arr = [] for _ in range(n): tmp = list(map(int,sys.stdin.readline().strip().split())) arr.append([tmp[0],tmp[1]]) arr = sorted(arr,key=lambda x: (..
[Python] ๋ฐฑ์ค€ #4659 - ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ฐœ์Œํ•˜๊ธฐ ๋ฌธ์ œ https://www.acmicpc.net/problem/4659 4659๋ฒˆ: ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ฐœ์Œํ•˜๊ธฐ ์ข‹์€ ํŒจ์Šค์›Œ๋“œ๋ฅผ ๋งŒ๋“œ๋Š”๊ฒƒ์€ ์–ด๋ ค์šด ์ผ์ด๋‹ค. ๋Œ€๋ถ€๋ถ„์˜ ์‚ฌ์šฉ์ž๋“ค์€ buddy์ฒ˜๋Ÿผ ๋ฐœ์Œํ•˜๊ธฐ ์ข‹๊ณ  ๊ธฐ์–ตํ•˜๊ธฐ ์‰ฌ์šด ํŒจ์Šค์›Œ๋“œ๋ฅผ ์›ํ•˜๋‚˜, ์ด๋Ÿฐ ํŒจ์Šค์›Œ๋“œ๋“ค์€ ๋ณด์•ˆ์˜ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค. ์–ด๋–ค ์‚ฌ์ดํŠธ๋“ค์€ xvtp www.acmicpc.net ํ’€์ด dic = {'a','e','i','o','u'} while True: ss = input() if ss == 'end': break check1 = False before1 = ['0',False] # ์ฒซ๋ฒˆ์งธ ์ „ (๋ฌธ์ž,๋ชจ์Œ ์—ฌ๋ถ€) before2 = ['0',False] # ๋‘๋ฒˆ์งธ ์ „ (๋ฌธ์ž,๋ชจ์Œ ์—ฌ๋ถ€) now = ['0',False] # # ํ˜„์žฌ (๋ฌธ์ž,๋ชจ์Œ ์—ฌ๋ถ€) for i,..
[Python] ๋ฐฑ์ค€ #2828 - ์‚ฌ๊ณผ ๋‹ด๊ธฐ ๊ฒŒ์ž„ ๋ฌธ์ œ https://www.acmicpc.net/problem/2828 2828๋ฒˆ: ์‚ฌ๊ณผ ๋‹ด๊ธฐ ๊ฒŒ์ž„ ์ƒ๊ทผ์ด๋Š” ์˜ค๋ฝ์‹ค์—์„œ ๋ฐ”๊ตฌ๋‹ˆ๋ฅผ ์˜ฎ๊ธฐ๋Š” ์˜ค๋ž˜๋œ ๊ฒŒ์ž„์„ ํ•œ๋‹ค. ์Šคํฌ๋ฆฐ์€ N์นธ์œผ๋กœ ๋‚˜๋ˆ„์–ด์ ธ ์žˆ๋‹ค. ์Šคํฌ๋ฆฐ์˜ ์•„๋ž˜์ชฝ์—๋Š” M์นธ์„ ์ฐจ์ง€ํ•˜๋Š” ๋ฐ”๊ตฌ๋‹ˆ๊ฐ€ ์žˆ๋‹ค. (M
[Python] ๋ฐฑ์ค€ #1992 - ์ฟผ๋“œํŠธ๋ฆฌ ๋ฌธ์ œ https://www.acmicpc.net/problem/1992 1992๋ฒˆ: ์ฟผ๋“œํŠธ๋ฆฌ ์ฒซ์งธ ์ค„์—๋Š” ์˜์ƒ์˜ ํฌ๊ธฐ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ์ˆซ์ž N ์ด ์ฃผ์–ด์ง„๋‹ค. N ์€ ์–ธ์ œ๋‚˜ 2์˜ ์ œ๊ณฑ์ˆ˜๋กœ ์ฃผ์–ด์ง€๋ฉฐ, 1 ≤ N ≤ 64์˜ ๋ฒ”์œ„๋ฅผ ๊ฐ€์ง„๋‹ค. ๋‘ ๋ฒˆ์งธ ์ค„๋ถ€ํ„ฐ๋Š” ๊ธธ์ด N์˜ ๋ฌธ์ž์—ด์ด N๊ฐœ ๋“ค์–ด์˜จ๋‹ค. ๊ฐ ๋ฌธ์ž์—ด์€ 0 ๋˜ www.acmicpc.net ํ’€์ด import sys n = int(input()) arr = [list(map(int,list(sys.stdin.readline().strip()))) for _ in range(n)] def tree(x,y,n): check = arr[x][y] # ์ฒดํฌํ•  ๊ธฐ์ค€ ์„ค์ • for i in range(x,x+n): for j in range(y,y+n): if check != a..
[Python] ๋ฐฑ์ค€ #2529 - ๋ถ€๋“ฑํ˜ธ ๋ฌธ์ œ https://www.acmicpc.net/problem/2529 2529๋ฒˆ: ๋ถ€๋“ฑํ˜ธ ๋‘ ์ข…๋ฅ˜์˜ ๋ถ€๋“ฑํ˜ธ ๊ธฐํ˜ธ ‘’๊ฐ€ k๊ฐœ ๋‚˜์—ด๋œ ์ˆœ์„œ์—ด A๊ฐ€ ์žˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ์ด ๋ถ€๋“ฑํ˜ธ ๊ธฐํ˜ธ ์•ž๋’ค์— ์„œ๋กœ ๋‹ค๋ฅธ ํ•œ ์ž๋ฆฟ์ˆ˜ ์ˆซ์ž๋ฅผ ๋„ฃ์–ด์„œ ๋ชจ๋“  ๋ถ€๋“ฑํ˜ธ ๊ด€๊ณ„๋ฅผ ๋งŒ์กฑ์‹œํ‚ค๋ ค๊ณ  ํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ์ œ์‹œ www.acmicpc.net ํ’€์ด n = int(input()) arr = list(input().split()) num = [False]*10 sol = [] answer = [] def dfs(cnt): if cnt==n: answer.append(''.join(map(str,sol))) # ์ˆซ์ž ๋‹ค ๋„ฃ์—ˆ์œผ๋ฉด answer์— ์ถ”๊ฐ€ return for i in range(10): # ๋‘๋ฒˆ์งธ ์ˆซ์ž๋ถ€ํ„ฐ ๋ถ€๋“ฑํ˜ธ ๋น„๊ต if num[i] =..
[Python] ๋ฐฑ์ค€ #14620 - ๊ฝƒ๊ธธ ๋ฌธ์ œ https://www.acmicpc.net/problem/14620 14620๋ฒˆ: ๊ฝƒ๊ธธ 2017๋…„ 4์›” 5์ผ ์‹๋ชฉ์ผ์„ ๋งž์ดํ•œ ์ง„์•„๋Š” ๋‚˜๋ฌด๋ฅผ ์‹ฌ๋Š” ๋Œ€์‹  ํ•˜์ดํ…Œํฌ๊ด€ ์•ž ํ™”๋‹จ์— ๊ฝƒ์„ ์‹ฌ์–ด ๋“ฑ๊ตํ•  ๋•Œ ๋งˆ๋‹ค ๊ฝƒ๊ธธ์„ ๊ฑท๊ณ  ์‹ถ์—ˆ๋‹ค. ์ง„์•„๊ฐ€ ๊ฐ€์ง„ ๊ฝƒ์˜ ์”จ์•—์€ ๊ฝƒ์„ ์‹ฌ๊ณ ๋‚˜๋ฉด ์ •ํ™•ํžˆ 1๋…„ํ›„์— ๊ฝƒ์ด ํ”ผ๋ฏ€ www.acmicpc.net ํ’€์ด import sys n = int(input()) arr = [list(map(int,sys.stdin.readline().strip().split())) for _ in range(n)] dx = [1,0,-1,0] dy = [0,1,0,-1] visited = [[False]*n for _ in range(n)] sol = 201*n*n def flower(cnt,c): globa..