Skip to content

Commit

Permalink
22.09.08
Browse files Browse the repository at this point in the history
  • Loading branch information
delena0702 authored Sep 8, 2022
1 parent 12e1c3b commit 8d23faf
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 0 deletions.
10 changes: 10 additions & 0 deletions BAEKJOON/10610_30.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
N = input()
if sum(map(lambda x: int(x), N)) % 3:
print(-1)
exit()

answer = list(sorted(N, reverse=True))
if answer[-1] == '0':
print(*answer, sep='')
else:
print(-1)
21 changes: 21 additions & 0 deletions BAEKJOON/11723_집합.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sys
def input(): return sys.stdin.readline().strip()

M = int(input())
s = 0
for _ in range(M):
query, *arr = input().split()
arr = list(map(int, arr))

if query == "add":
s = s | (1 << arr[0])
if query == "remove":
s = s & ~(1 << arr[0])
if query == "check":
print((s >> arr[0]) & 1)
if query == "toggle":
s = s ^ (1 << arr[0])
if query == "all":
s = 0x1fffff
if query == "empty":
s = 0
7 changes: 7 additions & 0 deletions BAEKJOON/15650_N과_M_(2).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from itertools import combinations
import sys
def input(): return sys.stdin.readline().strip()

N, M = map(int, input().split())
for arr in combinations(range(1, N + 1), M):
print(*arr)
21 changes: 21 additions & 0 deletions BAEKJOON/16502_그녀를_찾아서.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sys
def input(): return sys.stdin.readline().strip()

def index(ch): return ord(ch) - ord('A')

T = int(input())
M = int(input())
data = [[0] * 4 for _ in range(4)]
for _ in range(M):
a, b, p = input().split()
data[index(a)][index(b)] = float(p)

answer = [25] * 4
for _ in range(T):
next_answer = [0] * 4
for i in range(4):
for j in range(4):
next_answer[i] += answer[j] * data[j][i]
answer = next_answer
for i in range(4):
print(f"{answer[i]:.2f}")
41 changes: 41 additions & 0 deletions BAEKJOON/2583_영역_구하기.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from collections import deque
import sys
def input(): return sys.stdin.readline().strip()

darr = [(1, 0), (-1, 0), (0, 1), (0, -1)]

M, N, K = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(K)]
board = [[False] * N for _ in range(M)]

for x1, y1, x2, y2 in data:
for x in range(x1, x2):
for y in range(y1, y2):
board[y][x] = True

answer = []
for i in range(N * M):
sy, sx = divmod(i, N)
if board[sy][sx] == True:
continue

queue = deque([(sx, sy)])
board[sy][sx] = True
cnt = 1
while queue:
x, y = queue.popleft()
for dx, dy in darr:
nx, ny = x + dx, y + dy

if not 0 <= nx < N or not 0 <= ny < M:
continue
if board[ny][nx]:
continue

board[ny][nx] = True
cnt += 1
queue.append((nx, ny))
answer.append(cnt)

print(len(answer))
print(*sorted(answer))
34 changes: 34 additions & 0 deletions BAEKJOON/2667_단지번호붙이기.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from collections import deque
import sys
def input(): return sys.stdin.readline().strip()

darr = [(0, 1), (0, -1), (1, 0), (-1, 0)]

N = int(input())
data = [list(input()) for _ in range(N)]

answer = []
for i in range(N ** 2):
sy, sx = divmod(i, N)
if data[sy][sx] =='0':
continue

result = 0
queue = deque([(sx, sy)])
data[sy][sx] = '0'
while queue:
x, y = queue.popleft()
result += 1

for dx, dy in darr:
nx, ny = x + dx, y + dy
if not 0 <= nx < N or not 0 <= ny < N:
continue
if data[ny][nx] == '0':
continue
data[ny][nx] = '0'
queue.append((nx, ny))
answer.append(result)
print(len(answer))
answer.sort()
print(*answer, sep='\n')

0 comments on commit 8d23faf

Please sign in to comment.