๐ฅSilver 5 https://www.acmicpc.net/problem/10815 โ
1์ฐจ ํ์ดimport sysinput=sys.stdin.readlineanswer=''n=int(input())having_cards=set(map(int,input().rstrip().split()))m=int(input())num_list=list(map(int,input().rstrip().split()))for num in num_list: if num in having_cards: answer+='1' else: answer+='0'print(' '.join(answer))input์ ๋ฒ์๊ฐ 10^7์ผ๋ก ์ด๋ถํ์์ ํด์ผํ๋ ํ์ง๋ง, ์ผ๋จ ํ๋ฒ ์ ์งํ๊ฒ ํ์ด๋ณด์๋ค.์๊ทผ์ด..
๐ฅ Gold4 https://www.acmicpc.net/problem/10282 โ
์ ๋ต ํ์ดfrom sys import stdinfrom heapq import heappop,heappushinput = stdin.readlinet=int(input())INF=float('inf')def dijkstra(start): dist=[INF]*len(graph) dist[start]=0 q=[(0,start)] while q: cost,idx=heappop(q) if dist[idx] โจ ๊ฒฝ๋ก๋ ์๋ฐฉํฅ์ด ์๋์ง๋ง ๊ฐ์ผ์ ์ญ๋ฐฉํฅ์ผ๋ก ํผ์ ธ๋๊ฐ๊ธฐ ๋๋ฌธ์ ๊ทธ๋ํ์ ๊ฐ์ ๋ฃ์ด์ค๋ ์ญ๋ฐฉํฅ์ผ๋ก ๋ฃ์ด์ฃผ๋ฉด ๋๋ค.๊ทธ๋ ๊ฒ๋๋ฉด, ๊ฐ์ผ๋ ์ปดํจํฐ์ ๊ฐ์๋ ๋ค์ต์คํธ๋ผ ๊ฒฐ๊ณผ๊ฐ์ผ๋ก..
๐ฅ Gold4https://www.acmicpc.net/problem/1753 โ
์ ๋ตํ์ดimport sysfrom heapq import *input=sys.stdin.readlineINF=float('inf')def dijkstra(start): dist=[INF]*len(graph) dist[start]=0 #์์์ ๊ฑฐ๋ฆฌ๋ 0 q=[(0,start)] #(cost,๋
ธ๋๋ฒํธ) while q: cost,idx=heappop(q) if dist[idx] ์ฐ์ ์์ ํ๋ฅผ ์ด์ฉํ ๋ค์ต์คํธ๋ผ ์ต๋จ ๊ฒฝ๋ก ์๊ณ ๋ฆฌ์ฆ โ๏ธ์ ์ฒด ๋
ธ๋์ ๊ฐ์๊ฐ 10,000๊ฐ ์ด์์ด๋ผ๋ฉด, ๋ฆฌ์คํธ๊ฐ ์๋ ์ฐ์ ์์ ํ(ํ)์ ์ฌ์ฉํด ๋ฌธ์ ๋ฅผ ํ์ด์ผํ๋ค. ๐๐ป ๋ค์ต์คํธ๋ผ ์๊ณ ๋ฆฌ์ฆ ์๊ฐ ..
๐ฅ Silver3https://www.acmicpc.net/problem/8911 โ
์ ๋ตํ์ดimport sysinput = sys.stdin.readlinen = int(input()) dx = [0, 1, 0, -1]dy = [1, 0, -1, 0]for _ in range(n): commands = input().strip() direction = 0 # ์ด๊ธฐ๋ฐฉํฅ=๋ถ์ชฝ (0: ๋ถ, 1: ๋, 2: ๋จ, 3: ์) x, y = 0, 0 # ์ด๊ธฐ์์น min_x, min_y = 0, 0 max_x, max_y = 0, 0 for command in commands: if command == 'F': x += dx[di..
๐ฅ Silver2 https://www.acmicpc.net/problem/17086 โ
์ ๋ตํ์ดimport sysfrom collections import dequeinput = sys.stdin.readlinem, n = map(int, input().rstrip().split())dx = [0, 1, 1, 1, 0, -1, -1, -1]dy = [-1, -1, 0, 1, 1, 1, 0, -1]def bfs(): result = 0 while queue: cy, cx = queue.popleft() for i in range(8): ny, nx = dy[i] + cy, dx[i] + cx # ์์ด๊ฐ ์๋ 0์ ๋ํด ์ด๋ ..
๐ฅ Silver3 https://www.acmicpc.net/problem/1063 โ
์ ๋ต ํ์ดimport sysinput = sys.stdin.readlineking, stone, n = input().rstrip().split()# ์ด๋ ๋ฐฉํฅ (row,col)move = { 'R': (0, 1), 'L': (0, -1), 'B': (1, 0), 'T': (-1, 0), 'RT': (-1, 1), 'RB': (1, 1), 'LT': (-1, -1), 'LB': (1, -1)}cols = {'A': 0, 'B': 1, 'C': 2, 'D': 3, 'E': 4, 'F': 5, 'G': 6, 'H': 7} #{0:'A'}reversed_cols = {v: k for k, v in cols...
๐ฅ Silver5https://www.acmicpc.net/problem/1251 import sysfrom itertools import combinationsinput = sys.stdin.readlineword = list(input().strip())word_length = len(word)result = set()for i in range(1, word_length - 1): for j in range(i+1, word_length): first = word[:i] sec = word[i:j] thrid = word[j:] # reverse first.reverse() sec.reverse() thr..
๐ฅ Bronze3https://www.acmicpc.net/problem/2061 โ 1์ฐจ ํ์ดimport mathimport sysfrom itertools import permutations# ๋ ์์ ๊ตฌํ๊ธฐ# ๋ ์์๊ฐ l ์ด์์ธ์ง ํ์ธ# O - good# X - ๋ ์์ ์์ ์ถ๋ ฅinput = sys.stdin.readlinek, l = map(int, input().rstrip().split())for divisor in range(l,k): # ๋ ์์ ์ฐพ๊ธฐ if k%divisor==0: num2=k//divisor num1=divisor if num2์ฒ์์ ์๊ฐํ๋ ๋ฐฉ์์ ์ฃผ์ด์ง k=143๋ฅผ ์์ธ์๋ถํด ํ์๋ ์ถ์ถ๋๋ ๋ ๊ฐ์ด ๋ชจ๋ l์ด์์ด..