Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Week 23] BOJ 시뮬레이션 - 3문제 완료 #83

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: 23주차 BOJ 시뮬레이션 3문제 해결
  • Loading branch information
Gwonwoo-Nam committed Jul 26, 2023
commit 965727fcb24cb4cd2bba0db678dc51865e4b102e
24 changes: 24 additions & 0 deletions Gwonwoo-Nam/week_23/BOJ_1713_후보추천.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from collections import OrderedDict

n = int(input())
m = int(input())
numbers = map(int, input().split())

hit = OrderedDict()
for i in numbers :
if len(hit) < n :
if i not in hit.keys() :
hit[i] = 1
else :
hit[i] += 1
else :
if i not in hit.keys() :
key = list(hit.keys())
val = list(hit.values())
idx = val.index(min(val))
del(hit[key[idx]])
hit[i] = 1
else :
hit[i] += 1

print(" ".join(map(str,sorted(hit.keys()))))
67 changes: 67 additions & 0 deletions Gwonwoo-Nam/week_23/BOJ_21610_마법사 상어와 비바라기.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
n,m = map(int, input().split())

board = []
cloud = [[0 for i in range(n)] for j in range(n)]
cloud[n-1][0] = 1
cloud[n-1][1] = 1
cloud[n-2][0] = 1
cloud[n-2][1] = 1
move = [[0, -1],[-1, -1], [-1,0],[-1,1],[0,1],[1,1],[1,0],[1,-1]]

def moveCloud(d, s, board,cloud) :
dx, dy = move[d-1]
dx *= s
dy *= s
check = [[0 for i in range(n)] for j in range(n)]
for i in range(n) :
for j in range(n) :
if cloud[i][j] == 1 :
r,c = i+dx, j+dy
while r >= n :
r -= n
while r < 0 :
r += n
while c >= n :
c -= n
while c < 0 :
c += n
check[r][c] = 1
cloud[i][j] = 0
for i in range(n) :
for j in range(n) :
if check[i][j] == 1 :
cloud[i][j] = 1
board[i][j] += 1

def waterdup(d,s,board,cloud) :
m = [[-1, -1], [-1,1],[1,1],[1,-1]]
for i in range(n) :
for j in range(n) :
if cloud[i][j] == 1 :
for dx, dy in m :
if 0<=i+dx<n and 0<=j+dy<n and board[i+dx][j+dy] != 0 :
board[i][j] += 1

def cloudtemp(d,s,board,cloud) :
for i in range(n) :
for j in range(n) :
if board[i][j] >= 2 and cloud[i][j] != 1:
cloud[i][j] = 1
board[i][j] -= 2
elif cloud[i][j] == 1 :
cloud[i][j] = 0

for i in range(n) :
r = list(map(int, input().split()))
board.append(r)
for i in range(m) :
d, s = map(int, input().split())

moveCloud(d,s,board,cloud)
waterdup(d,s,board,cloud)
cloudtemp(d,s,board,cloud)

result = 0
for i in board :
result += sum(i)
print(result)
46 changes: 46 additions & 0 deletions Gwonwoo-Nam/week_23/BOJ_5212_지구온난화.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
r,c = map(int, input().split())

def check(i,j, li) :
dir = [[1,0], [0,1], [-1,0], [0, -1]]
t = 0
for dx, dy in dir :
if i+dx < r and i+dx >= 0 and j+dy < c and j+dy >= 0 :
if li[i+dx][j+dy] == '.' :
t += 1
else :
t += 1
if t >= 3 :
return True
return False


li = []
for i in range(r) :
li.append(list(input()))

for i in range(r) :
for j in range(c) :
if li[i][j] == 'X' :
if check(i,j, li) :
li[i][j] = 'O'

minr = 100
minc = 100
maxr = 0
maxc = 0
for i in range(r) :
for j in range(c) :
if li[i][j] == 'O' :
li[i][j] = '.'
if li[i][j] == 'X' :
minr = min(minr, i)
minc = min(minc, j)
maxr = max(maxr, i)
maxc = max(maxc, j)

for i in range(minr, maxr+1) :
for j in range(minc, maxc+1) :
print(li[i][j], end='')
print()