코테 준비
-
[백준] 5430. AC (다시 풀어보기)코테 준비/구현 2023. 1. 27. 03:31
첫번째 시도 (시간초과) - reverse를 매번 해줘서 타임아웃 from collections import deque import sys t=int(sys.stdin.readline()) for i in range(t): p=sys.stdin.readline() n=int(sys.stdin.readline()) x=deque(sys.stdin.readline().rstrip()[1:-1].split(',')) for i in range(n): x[i]=int(x[i]) if n==0: print('error') else: for j in p: if j=='R': x.reverse() elif j=='D': if x: x.popleft() else: print("error") print(list(x)) ..
-
[백준] 1002. 터렛코테 준비/구현 2023. 1. 26. 04:01
import math t=int(input()) for i in range(t): x1,y1,r1,x2,y2,r2=map(int,input().split()) distance=math.sqrt((x1-x2)**2+(y1-y2)**2) #두 원 사이의 거리 if x1==x2 and y1==y2 and r1==r2: #두 원이 일치하는 경우 print(-1) elif r1+r2==distance or abs(r1-r2)==distance: #두원이 한점에서 만나는 경우 print(1) elif r1+r2>distance and abs(r1-r2)
-
[프로그래머스] 3차 압축 (LZW 알고리즘)코테 준비/구현 2023. 1. 26. 03:25
from string import ascii_uppercase def solution(msg): answer=[] alphabet = {} for i in range(len(ascii_uppercase)): alphabet[ascii_uppercase[i]] = i+1 #알파벳 만들기 k=0 #start i=len(msg) #end while True: if msg[k:i] in alphabet: answer.append(alphabet[msg[k:i]]) if i>=len(msg): return answer # while 문 종료 alphabet[msg[k:i+1]]=len(alphabet)+1 k+=len(msg[k:i]) i=len(msg) else: #이미 알파벳에 있으면 i-=1 #end 길이 -1
-
[백준] 1269. 대칭 차집합코테 준비/Hash map 2023. 1. 24. 03:48
from collections import Counter anum,bnum=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) count1=Counter(a) count2=Counter(b) print(len(list((count1-count2).elements()))+len(list((count2-count1).elements())))