-
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
9-suhyun113 #33
Merged
Merged
9-suhyun113 #33
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
18ce7d3
2024-04-14 ์ปจํธ๋กค ์ ํธ
suhyun113 c298587
2024-05-09 ์์ญ์ด ๋งค๋ฌ๊ธฐ
suhyun113 bb52b7a
Revert "2024-05-09 ์์ญ์ด ๋งค๋ฌ๊ธฐ"
suhyun113 0ea79f5
2024-05-09 ์์ญ์ด ๋งค๋ฌ๊ธฐ
suhyun113 a76468a
Update README.md
suhyun113 c3f2229
2024-05-14 ์ด๋ฆฐ ์์
suhyun113 5c53701
2024-05-28 ์ต์๋น์ฉ ๊ตฌํ๊ธฐ
suhyun113 8921313
Revert "2024-05-28 ์ต์๋น์ฉ ๊ตฌํ๊ธฐ"
suhyun113 7136243
2024-05-28 ์ต์๋น์ฉ ๊ตฌํ๊ธฐ
suhyun113 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# 1916 : ์ต์๋น์ฉ ๊ตฌํ๊ธฐ | ||
|
||
import heapq | ||
|
||
INF = float('inf') # ์ต๋๊ฐ ์ ์ | ||
|
||
N = int(input()) # ๋์์ ๊ฐ์(๋ ธ๋) | ||
M = int(input()) # ๋ฒ์ค์ ๊ฐ์(์์ง) | ||
|
||
graph = [[] for _ in range(N+1)] # ๊ทธ๋ํ ์ธ์ ๋ฆฌ์คํธ๋ก ์ด๊ธฐํ(๋ฐฉ๋ฌธํ์ง ์์ ๋ ธ๋๋ค) | ||
distance = [INF] * (N+1) # ๊ฐ ๋ ธ๋๊น์ง์ ๊ฑฐ๋ฆฌ ๋ฌดํ๋๋ก ์ด๊ธฐํ | ||
|
||
for _ in range(M): | ||
x, y, cost = map(int, input().split()) # x -> y ๋์๋ก ๊ฐ๋ ๋ฐ ํ์ํ ๋น์ฉ cost | ||
graph[x].append([y, cost]) # ๊ทธ๋ํ์ ์์ง ์ถ๊ฐ | ||
|
||
start, end = map(int, input().split()) # ์ถ๋ฐ, ๋์ฐฉ ๋ ธ๋ ์ ๋ ฅ ๋ฐ๊ธฐ | ||
|
||
# ๋ค์ต์คํธ๋ผ ์๊ณ ๋ฆฌ์ฆ | ||
def Dijkstra(start): | ||
q = [] # ์ฐ์ ์์ ํ ์์ฑ | ||
heapq.heappush(q, [0, start]) # ์ถ๋ฐํ ๋์ ํ์ ๋ฃ๊ธฐ([๊ฑฐ๋ฆฌ, ๋ ธ๋] ํํ) | ||
distance[start] = 0 # ์์ ๋์์ ๊ฑฐ๋ฆฌ 0์ผ๋ก ์ด๊ธฐํ | ||
|
||
while q: # ํ๊ฐ ๋น ๋๊น์ง ๋ฐ๋ณต | ||
weight, node = heapq.heappop(q) # ํ์ฌ ๋ ธ๋๊น์ง์ ๊ฑฐ๋ฆฌ, ํ์ฌ ๋ ธ๋(ํ์์ ๊ฐ์ฅ ์์ ๊ฐ) | ||
if distance[node] < weight: # ํ์ฌ ๋ ธ๋๊ฐ ์ด๋ฏธ ์ฒ๋ฆฌ๋ ๋ ธ๋์ธ์ง ํ์ธ | ||
continue | ||
for n, w in graph[node]: | ||
cost = w + weight # ํ์ฌ ๋ ธ๋๋ฅผ ํตํด ์ธ์ ๋ ธ๋๊น์ง ๊ฐ๋ ์๋ก์ด ๊ฑฐ๋ฆฌ ๊ณ์ฐ | ||
if distance[n] > cost: # ์๋ก์ด ๊ฑฐ๋ฆฌ๊ฐ ๊ธฐ์กด์ ์ ์ฅ๋ ๊ฑฐ๋ฆฌ๋ณด๋ค ์งง์์ง ํ์ธ | ||
distance[n] = cost # ์ต๋จ ๊ฑฐ๋ฆฌ ๊ฐฑ์ | ||
heapq.heappush(q, [cost, n]) # ์ธ์ ๋ ธ๋๋ฅผ ์ฐ์ ์์ ํ์ ์ถ๊ฐ | ||
|
||
Dijkstra(start) | ||
print(distance[end]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 1004 : ์ด๋ฆฐ ์์ | ||
|
||
#include <iostream> | ||
#include <cmath> | ||
using namespace std; | ||
|
||
int main() { | ||
int T; // ํ ์คํธ ์ผ์ด์ค์ ๊ฐ์ | ||
int x1, y1, x2, y2; // ์ถ๋ฐ์ , ๋์ฐฉ์ | ||
int n; // ํ์ฑ์ ๊ฐ์ | ||
int cx, cy, r; // ํ์ฑ๊ณ์ ์ค์ ๊ณผ ๋ฐ์ง๋ฆ | ||
|
||
cin >> T; | ||
while(T--) { | ||
cin >> x1 >> y1 >> x2 >> y2; | ||
cin >> n; | ||
|
||
int enter = 0; // ์ง์ ํ์ | ||
int departure = 0; // ์ดํ ํ์ | ||
int count = 0; // ์ต์ข ์ง์ /์ดํ ํ์ | ||
|
||
while(n--) { | ||
cin >> cx >> cy >> r; | ||
float startDistance = sqrt(pow(cx - x1, 2) + pow(cy - y1, 2)); // ์ถ๋ฐ์ ๊ณผ ์ ์ฌ์ด์ ๊ฑฐ๋ฆฌ | ||
float endDistance = sqrt(pow(cx - x2, 2) + pow(cy - y2, 2)); // ๋์ฐฉ์ ๊ณผ ์ ์ฌ์ด์ ๊ฑฐ๋ฆฌ | ||
|
||
if (startDistance < r){ // ์ถ๋ฐ์ ์ด ์ ๋ด๋ถ์ ์๊ณ , | ||
if (endDistance > r) { // ๋์ฐฉ์ ์ด ์ ์ธ๋ถ์ ์์ | ||
departure++; // ์ถ๋ฐ์ ํฌํจํ๋ ํ์ฑ -> ์ดํ ํ์ ์ฆ๊ฐ | ||
} | ||
} | ||
if (startDistance > r) { // ์ถ๋ฐ์ ์ด ์ ์ธ๋ถ์ ์๊ณ , | ||
if (endDistance < r) { // ๋์ฐฉ์ ์ด ์ ๋ด๋ถ์ ์์ | ||
enter++; // ๋์ฐฉ์ ํฌํจํ๋ ํ์ฑ -> ์ง์ ํ์ ์ฆ๊ฐ | ||
} | ||
} | ||
} | ||
count = enter + departure; // ์ต์ข ์ง์ /์ดํ ํ์ | ||
cout << count << endl; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
def solution(s): | ||
answer = 0 | ||
|
||
stack = [float("inf")] | ||
|
||
# ๋ฌธ์์ด์ ๊ณต๋ฐฑ ๊ธฐ์ค์ผ๋ก ๋๋์ด ๋ฆฌ์คํธ์ ์ ์ฅ | ||
s_list = s.split() | ||
|
||
for i in s_list: # i๋ s_list์ ์ธ๋ฑ์ค๊ฐ ์๋ ๊ฐ | ||
if i != 'Z': | ||
stack.append(i) | ||
else: | ||
stack.pop() # stack์ ๊ฐ์ฅ ์์ ๊ฐ ๋นผ๊ธฐ | ||
stack.pop(0) | ||
|
||
# ๋ฌธ์๋ฅผ ์ ์๋ก ๋ณํํ๊ธฐ | ||
for i in stack: | ||
n = int(i) | ||
answer += n | ||
return answer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# 2716 : ์์ญ์ด ๋งค๋ฌ๊ธฐ | ||
|
||
N = int(input()) # ํ ์คํธ ์ผ์ด์ค์ ๊ฐ์ | ||
results = [] | ||
|
||
for _ in range(N): | ||
s = input().strip() | ||
len_s = len(s) | ||
|
||
depth = 0 | ||
max_depth = 0 | ||
|
||
for i in range(len_s): | ||
if (s[i] == '['): | ||
depth += 1 | ||
if (depth > max_depth): | ||
max_depth = depth | ||
elif (s[i] == ']'): | ||
depth -= 1 | ||
|
||
result = 1 #๋๋ฌด ๊ผญ๋๊ธฐ ๋๋ฌ์ํด ์ต์ ํ ๋ง๋ฆฌ ์์ญ์ด ํ์ | ||
for _ in range(max_depth): | ||
result *= 2 | ||
results.append(result) | ||
|
||
for result in results: | ||
print(result) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
์ฌ์ํ ํ์ธ๋ฐ, graph์ ์ ๋ณด๋ "๋ถ๋ณ"์ด๋ฏ๋ก (์ธ์ ๋ ธ๋, ๋น์ฉ) ์ ๋ณด๋ฅผ list๋ก ๋ฃ์ง ๋ง๊ณ tuple๋ก ๋ฃ์ผ๋ฉด ๋ฉ๋ชจ๋ฆฌ์ ์๋ ์ธก๋ฉด์์ ์ฝ๊ฐ ๊ฐ์ ๋ฉ๋๋ค :)