분류 전체보기

코딩테스트/코딩테스트 문제풀이

[Python] 백준 <16472-고냥이>

https://www.acmicpc.net/problem/16472 import sysinput = sys.stdin.readlineN = int(input())S = input().strip()start = 0end = 0counter = dict()dap = 0# end를 0번째부터 하나씩 넣으면서 카운트 및 알파벳 개수 비교while end N: # start 이동 counter[S[start]] -= 1 if counter[S[start]] == 0: del counter[S[start]] start += 1 # 기준을 만족하면 길이 구하고 최대값 비교 dap = max(dap, end-start+1) # en..

코딩테스트/코딩테스트 문제풀이

[Python] 백준 <1062-가르침>

https://www.acmicpc.net/problem/1062 - pypy3로 통과import sysinput = sys.stdin.readline# 배울 수 있는 경우의 수 다 구하고 # 각 경우의 수가 완성되면 배울 수 있는 단어 개수 비교# n으로 글자수 카운트def dfs(x, n): global dap if n == K: cnt = 0 for i in li: boo = True for j in i: # 배우지 않은 글자가 포함이면 False if visited[ord(j)-ord('a')] == 0: boo = False ..

코딩테스트/코딩테스트 문제풀이

[Python] 백준 <1034-램프>

https://www.acmicpc.net/problem/1034 import sysinput = sys.stdin.readlineN, M = map(int, input().split(" "))li = list()for _ in range(N): li.append(input().strip())K = int(input())dap = 0for i in range(N): row = li[i] zero_count = row.count('0') # 같은 패턴이고 0개수가 K보다 작으며 남은 횟수가 짝수면 카운트 if zero_count - 다른 방법 (Counter)import sysfrom collections import Counterinput = sys.stdin.readline..

코딩테스트/코딩테스트 문제풀이

[Python] 백준 <9663-N-Queen>

https://www.acmicpc.net/problem/9663 import sysinput = sys.stdin.readlineN = int(input())ans = 0row = [0]*Ndef is_promising(x): for i in range(x): if row[x] == row[i] or abs(row[x] - row[i]) == abs(x - i): return False return Truedef n_queens(x): global ans if x == N: ans += 1 return else: for i in range(N): # [x, i]에 퀸을 놓음 ..

Yang Ji Woo
'분류 전체보기' 카테고리의 글 목록 (18 Page)