Skip to content

[이지민] - 순회강연, 용액, 맥주 마시면서 걸어가기, 혼자서 하는 틱택토 #279

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

Merged
merged 4 commits into from
Jun 9, 2024
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
33 changes: 33 additions & 0 deletions src/main/kotlin/jimin/66week/맥주 마시면서 걸어가기.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys
from collections import deque

t = int(sys.stdin.readline())
for i in range(t):
n = int(sys.stdin.readline())
home = list(map(int, sys.stdin.readline().split()))
stores = []
for j in range(n):
stores.append(list(map(int, sys.stdin.readline().split())))
festival = list(map(int, sys.stdin.readline().split()))
visited = [False for _ in range(n)]

queue = deque([])
queue.append(home)
isPossible = False
while queue:
nx, ny = queue.popleft()
if abs(nx - festival[0]) + abs(ny - festival[1]) <= 20 * 50:
isPossible = True
break

for i in range(n):
if not visited[i]:
if abs(nx - stores[i][0]) + abs(ny - stores[i][1]) <= 20 * 50:
visited[i] = True
queue.append(stores[i])

if isPossible:
print("happy")
else:
print("sad")

20 changes: 20 additions & 0 deletions src/main/kotlin/jimin/66week/순회강연.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import sys

n = int(sys.stdin.readline())
classes = []
maxi = 0
for i in range(n):
classes.append(list(map(int, sys.stdin.readline().split())))
maxi = max(maxi, classes[-1][1])

classes.sort(reverse=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헉 이게 우선순위를 거꾸로 하겟다가 아니고 내림차순으로 정렬하겠다는 거였군요...똑똑한 파이썬

visited = [0 for _ in range(maxi + 1)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

범위를 미리 구해서 maxi까지로 되는 게 좋네요

for i in range(n):
p, d = classes[i]

for j in range(d, 0, -1):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

파이썬은 이런게 엄청 직관적인 것 같아 부럽습니다

if visited[j] == 0:
visited[j] = p
break
Comment on lines +12 to +18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

큰 비용부터 시작해서 최대 날짜부터 visited 처리하는 풀이군요! 저랑 풀이가 달라서 보기 좋았슴다!


print(sum(visited))
22 changes: 22 additions & 0 deletions src/main/kotlin/jimin/66week/용액.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import sys

n = int(sys.stdin.readline())
feats = list(map(int, sys.stdin.readline().split()))

start = 0
end = n - 1
mini = 2_000_000_000
ms, me = feats[0], feats[n - 1]
while start < end:
if mini > abs(feats[start] + feats[end]):
mini = abs(feats[start] + feats[end])
ms, me = feats[start], feats[end]

if feats[start] + feats[end] < 0:
start += 1
elif feats[start] + feats[end] > 0:
end -= 1
else:
break

print(ms, me)
76 changes: 76 additions & 0 deletions src/main/kotlin/jimin/66week/혼자서 하는 틱택토.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
def solution(board):
x = 0
o = 0
for i in range(3):
for j in range(3):
if board[i][j] == 'X':
x += 1
elif board[i][j] == 'O':
o += 1

if x > o:
return 0
if x == 0 and o == 0:
return 1
if o - x > 1:
return 0

x_bingo = 0
o_bingo = 0
for i in range(3):
# 가로
first = board[i][0]
if first == '.':
continue
Comment on lines +22 to +24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

설명하시는 도중에 오류 찾으시는 게 멋졌습니다🥹


isBingo = True
for j in range(1, 3):
if first != board[i][j]:
isBingo = False
break

if isBingo:
if first == 'X':
x_bingo += 1
elif first == 'O':
o_bingo += 1

for i in range(3):
# 세로
first = board[0][i]
if first == '.':
continue

isBingo = True
for j in range(1, 3):
if first != board[j][i]:
isBingo = False
break

if isBingo:
if first == 'X':
x_bingo += 1
elif first == 'O':
o_bingo += 1

# 대각선
if board[0][0] != '.' and board[0][0] == board[1][1] and board[1][1] == board[2][2]:
if board[0][0] == 'X':
x_bingo += 1
elif board[0][0] == 'O':
o_bingo += 1
elif board[0][2] != '.' and board[0][2] == board[1][1] and board[1][1] == board[2][0]:
if board[0][2] == 'X':
x_bingo += 1
elif board[0][2] == 'O':
o_bingo += 1

if o_bingo > x_bingo and o == x + 1:
return 1
if o_bingo < x_bingo and o == x:
return 1
if o_bingo == 0 and x_bingo == 0:
return 1

return 0