-
Notifications
You must be signed in to change notification settings - Fork 0
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
[이지민] - CCW, 전구와 스위치, 케빈 베이컨의 6단계 법칙, 함께 블록 쌓기 #173
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
''' | ||
1도 모르겠습니다. | ||
수학 다 까먹었습니다.. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 인정...
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ㅋㅋㅋㅋㅋㅋ ㅠㅠ... |
||
https://growth-coder.tistory.com/163 | ||
''' | ||
|
||
p1_x, p1_y = map(int, input().split()) | ||
p2_x, p2_y = map(int, input().split()) | ||
p3_x, p3_y = map(int, input().split()) | ||
|
||
res = p1_x * p2_y + p2_x * p3_y + p3_x * p1_y - (p2_x * p1_y + p3_x * p2_y + p1_x * p3_y) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 반복문 쓰는 것보다 이렇게 하는게 훨씬 깔끔하네요 |
||
|
||
if res > 0: | ||
print(1) | ||
elif res < 0: | ||
print(-1) | ||
else: | ||
print(0) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
''' | ||
https://astrid-dm.tistory.com/429 | ||
첫번째 전구를 누르고 시작하는 경우, | ||
첫번째 전구를 누르지 않고 시작하는 경우 | ||
2가지를 구해서 적은 횟수로 출력! | ||
''' | ||
|
||
n = int(input()) | ||
before = list(map(int, list(input()))) | ||
after = list(map(int, list(input()))) | ||
|
||
# 첫번째 전구 안누름 | ||
now_1 = before[:] | ||
num_1 = 0 | ||
for i in range(0, n - 1): | ||
if now_1[i] != after[i]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 앞이 아닌 본인을 기준으로 하는군요! |
||
num_1 += 1 | ||
now_1[i] = 1 - now_1[i] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1 - 값 좋네요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 개천재 모먼트.. ㄷㄷ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 헐 내껀데 뺏겼다,,, |
||
now_1[i + 1] = 1 - now_1[i + 1] | ||
if i + 2 < n: | ||
now_1[i + 2] = 1 - now_1[i + 2] | ||
|
||
now_2 = before[:] | ||
now_2[0] = not now_2[0] | ||
now_2[1] = not now_2[1] | ||
num_2 = 1 | ||
for i in range(0, n - 1): | ||
if now_2[i] != after[i]: | ||
num_2 += 1 | ||
now_2[i] = 1 - now_2[i] | ||
now_2[i + 1] = 1 - now_2[i + 1] | ||
if i + 2 < n: | ||
now_2[i + 2] = 1 - now_2[i + 2] | ||
|
||
if now_1 != after and now_2 == after: | ||
print(num_2) | ||
elif now_2 != after and now_1 == after: | ||
print(num_1) | ||
elif now_1 == after and now_2 == after: | ||
print(min(num_1, num_2)) | ||
else: | ||
print(-1) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from collections import defaultdict | ||
from collections import deque | ||
|
||
def getBaconNum(n): | ||
global bacons | ||
q = deque([n]) | ||
visited = [0 for _ in range(len(bacons) + 1)] | ||
num = 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 얘 안 쓰이는 것 같아요~~! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 그러네요 눈썰미 대박!! |
||
while q: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이런게 너무 신기합ㄴ디ㅏ 파이썬,,, |
||
now = q.popleft() | ||
for i in bacons[now]: | ||
if visited[i] == 0 and i != n: | ||
visited[i] = visited[now] + 1 | ||
q.append(i) | ||
num += 1 | ||
return sum(visited) | ||
|
||
|
||
n, m = map(int, input().split()) | ||
bacons = defaultdict(list) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 새로운 거 알아갑니다..!! |
||
|
||
for i in range(m): | ||
a, b = map(int, input().split()) | ||
bacons[a].append(b) | ||
bacons[b].append(a) | ||
|
||
mini = 500001 | ||
result = 0 | ||
for i in range(1, n + 1): | ||
num = getBaconNum(i) | ||
if mini > num: | ||
result = i | ||
mini = num | ||
print(result) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
''' | ||
https://magentino.tistory.com/234 | ||
이해안감 | ||
''' | ||
|
||
n, m, h = map(int, input().split()) | ||
students = [] | ||
for i in range(n): | ||
students.append([0] + list(map(int, input().split()))) | ||
|
||
dp = [[0 for _ in range(h + 1)] for _ in range(n + 1)] | ||
dp[0][0] = 1 | ||
|
||
for i in range(n): | ||
for j in range(h + 1): | ||
if dp[i][j]: | ||
for s in students[i]: | ||
if j + s <= h: | ||
dp[i + 1][j + s] = (dp[i + 1][j + s] + dp[i][j]) % 10007 | ||
Comment on lines
+14
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 헉 여기 코드기 디게 깔꼼쓰 하네요👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. += 연산 후에 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵! 이게 더 연산이 빠를 것 같기두 하고요?? |
||
|
||
print(dp[-1][-1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저두욧^^...