[BaekJoon] 1012 ์œ ๊ธฐ๋† ๋ฐฐ์ถ”
ยท
๐Ÿ’ฏ CodingTest/BaekJoon
โ–ถ ๋ฌธ์ œ : ๋”๋ณด๊ธฐ https://www.acmicpc.net/problem/1012 import sys t = int(input()) sys.setrecursionlimit(10**6) def dfs(a, b): if a = m or b = n: return if graph[a][b] == 0: return graph[a][b] = 0 dfs(a - 1, b) dfs(a, b - 1) dfs(a + 1, b) dfs(a, b + 1) for _ in range(t): m, n, k = map(int, input().split()) graph = [[0 for _ in range(n)]for _ in range(m)] for _ in range(k): a, b = ma..
[BaekJoon] 1003 ํ”ผ๋ณด๋‚˜์น˜ ํ•จ์ˆ˜
ยท
๐Ÿ’ฏ CodingTest/BaekJoon
โ–ถ ๋ฌธ์ œ ๋”๋ณด๊ธฐ https://www.acmicpc.net/problem/1003 import sys n = int(sys.stdin.readline().rstrip()) data = {i : 0 for i in range(41)} # ์ˆซ์ž์˜ ์ตœ๋Œ€๊ฐ’์ด 40 result = [[0, 0] for i in range(41)] result[0][0] = 1 result[1][1] = 1 def fibo(n): if n == 0: return 0 elif n == 1: return 1 elif data[n] > 0: return data[n] else: data[n] = fibo(n-1) + fibo(n-2) result[n][0], result[n][1] = result[n-1][0] + result[n-2]..
[BaekJoon] 18111 ๋งˆ์ธํฌ๋ž˜ํ”„ํŠธ
ยท
๐Ÿ’ฏ CodingTest/BaekJoon
import sys n, m, b = map(int,sys.stdin.readline().rstrip().split()) groundHeight = [list(map(int,sys.stdin.readline().rstrip().split())) for i in range(n)] #numOfH ={i:0 for i in range(257)} linearGround = [] minH = 256 maxH = 0 for raw in groundHeight : if min(raw) maxH: maxH = max(raw) for h in raw: linearGround.append(h) linearGround.sort(reverse=True) ..
[BaekJoon] 15829 Hashing
ยท
๐Ÿ’ฏ CodingTest/BaekJoon
n = int(input()) word = input() result = 0 alpha = { 'a':1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7, 'h':8, 'i':9, 'j':10, 'k':11, 'l':12, 'm':13, 'n':14, 'o':15, 'p':16, 'q':17, 'r':18, 's':19, 't':20, 'u':21, 'v':22, 'w':23, 'x':24, 'y':25, 'z':26, } for i in range(len(word)): result += alpha[word[i]] * (31**i) print(result % 1234567891) ๋ฌธ์ œํ’€์ด 1. ๊ฐ ์•ŒํŒŒ๋ฒณ ๊ฐ’์„ ์ง€์ •ํ–ˆ๋‹ค. => ์•„์Šคํ‚ค์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•ด๋„ ๋˜์ง€๋งŒ ํ•œ๋ฒˆ ์ด๋ ‡๊ฒŒ ํ•ด๋ณด๊ณ  ์‹ถ์—ˆ..
[BaekJoon] 2805 ๋‚˜๋ฌด์ž๋ฅด๊ธฐ
ยท
๐Ÿ’ฏ CodingTest/BaekJoon
n, m = map(int,input().split()) treeHeight = list(map(int, input().split())) # ์ ์–ด๋„ M๋ฏธํ„ฐ์˜ ๋‚˜๋ฌด๋ฅผ ์ง‘์— ๊ฐ€์ ธ๊ฐ€๊ธฐ ์œ„ํ•ด์„œ ์ ˆ๋‹จ๊ธฐ์— ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋Š” ๋†’์ด์˜ ์ตœ๋Œ“๊ฐ’์„ ์ถœ๋ ฅํ•œ๋‹ค. treeHeight.sort() resultList=list() def binarySearch(data, m2): low = 1 # m์€ 1= m2: # mid(H) ๊ฐ’์„ ๋†’์—ฌ์„œ ํƒ์ƒ‰ํ•ด์•ผํ•จ if result < mid : result = mid low = mid + 1 else: high = mid - 1 return result #print(max(resultList)) #์ด๋ ‡๊ฒŒ max () ๋ฅผ ์‚ฌ์šฉํ–ˆ์„๋•Œ ์ฝœ์Šคํƒ ์ดˆ๊ณผ๊ฐ€ ๋‚˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์„ ์ˆ˜๋„ ์žˆ์Œ ๋”ฐ๋ผ์„œ ๊ฐ’์„ ๊ณ„์† ๋ณ€..
[BaekJoon] 1654 ๋žœ์„  ์ž๋ฅด๊ธฐ
ยท
๐Ÿ’ฏ CodingTest/BaekJoon
k, n = map(int,input().split()) kLength = list() result = list() for i in range(k): kLength.append(int(input())) kLength.sort() def binarySearch(data, n2): low=1 # ๋žœ์„ ์˜ ๊ธธ์ด๋Š” ์ž์—ฐ์ˆ˜๋ผ๊ณ  ๋ช…์‹œ๋˜์–ด์žˆ๋‹ค.. # ์กฐ์‹ฌํ•˜์ž.. # low๋ฅผ 0์œผ๋กœ ํ•ด๋†“๊ณ  ํ—›์ง“๊ฑฐ๋ฆฌํ•จ.. high = data[len(data)-1] + 1 ''' 4 4 100 100 100 100 ๊ณผ ๊ฐ™์€ ์ž…๋ ฅ์ด ๋“ค์–ด์™”์„๋•Œ high๊ฐ’๋„ ํƒ์ƒ‰ ๋ฒ”์œ„์— ํฌํ•จ์‹œํ‚ค๊ธฐ ์œ„ํ•ด 1๋”ํ•ด์ฃผ๊ธฐ. ''' while (low ๊ทธ ํ›„ ์ •๋ ฌ 3. ์ด์ง„ ํƒ์ƒ‰ ํ•จ์ˆ˜ ์ž‘์„ฑ => ๊ฐ ์ค‘๊ฐ„๊ฐ’์„ ๋ฐ˜๋ณตํ• ๋•Œ๋งˆ๋‹ค ๊ทธ๋•Œ ๊ธธ์ด๋กœ ๊ฐ๊ฐ์˜ ๋žœ์„ ์—์„œ ๋‚˜์˜ฌ ์ˆ˜ ์žˆ๋Š” ๊ฐœ์ˆ˜๋ฅผ..
[BaekJoon] 10845 ํ
ยท
๐Ÿ’ฏ CodingTest/BaekJoon
โ–ถ ์ž๋ฃŒ๊ตฌ์กฐ ํ(Queue)๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ๋ฌธ์ œ์ด๋‹ค. import sys n = int(sys.stdin.readline().rstrip()) q = list() while n > 0: cmd = sys.stdin.readline().rstrip() ## .rstrip() ๋ฅผ ์•ˆ๋ถ™์—ฌ ์ฃผ๋ฉด ์ž…๋ ฅ๊ฐ’์ด ์˜ˆ๋ฅผ๋“ค์–ด "push 1" ์ธ๊ฒฝ์šฐ cmd์—๋Š” "push 1\n" ์œผ๋กœ ๊ฐœํ–‰ ๋ฌธ์ž์—ด๊นŒ์ง€ ํฌํ•จ๋œ๋‹ค. ๋”ฐ๋ผ์„œ .rstrip()๋ฅผ ๋ถ™์—ฌ ์˜ฌ๋ฐ”๋ฅธ ์ž…๋ ฅ์„ ๋ฐ›๋„๋กํ•œ๋‹ค. val = '' if ' ' in cmd: cmd, val = cmd.split() val = int(val) if cmd == 'push': q.append(val) elif cmd == 'pop': if len(q) == 0: sys.stdout.write(s..