Skip to content

Commit 22dee9a

Browse files
committed
2 parents 529e82d + 7178295 commit 22dee9a

25 files changed

+305
-270
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from collections import deque
2+
3+
def topology_sort(graph, inDegree):
4+
queue = deque()
5+
6+
result = [-1] * (N+1)
7+
8+
9+
# 진입차수가 0인 정점을 queue에 추가
10+
for i in range(1, N+1):
11+
if inDegree[i] == 0:
12+
queue.append(i)
13+
result[i] = 1
14+
15+
16+
while queue:
17+
now = queue.popleft()
18+
19+
for vertex in graph[now]:
20+
inDegree[vertex] -= 1
21+
if inDegree[vertex] == 0:
22+
queue.append(vertex)
23+
result[vertex] = result[now] + 1
24+
25+
return result
26+
27+
28+
29+
# 입력값 받기
30+
N, M = map(int, input().split())
31+
32+
# 과목 개수만큼 이차원 리스트 만들기
33+
graph = [ [] for _ in range(N+1)]
34+
35+
# 진입차수 리스트
36+
inDegree = [0] * (N+1)
37+
result = [] * (N+1)
38+
39+
for i in range(M):
40+
A, B = map(int, input().split())
41+
graph[A].append(B)
42+
inDegree[B] += 1
43+
44+
result = topology_sort(graph, inDegree)
45+
for i in range(1,N+1):
46+
print(result[i], end=" ")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
T = int(input())
2+
result = []
3+
4+
for _ in range(T):
5+
# 출발점 도착점
6+
x1, y1, x2, y2 = list(map(int, input().split()))
7+
# 행성계의 개수
8+
n = int(input())
9+
count = 0
10+
for _ in range(n):
11+
cx, cy, cr = map(int, input().split())
12+
dis1 = (x1 - cx) ** 2 + (y1 - cy) ** 2
13+
dis2 = (x2 - cx) ** 2 + (y2 - cy) ** 2
14+
pow_cr = cr ** 2
15+
16+
if pow_cr > dis1 and pow_cr > dis2:
17+
pass
18+
elif pow_cr > dis1:
19+
count += 1
20+
elif pow_cr > dis2:
21+
count += 1
22+
result.append(count)
23+
24+
for i in result:
25+
print(i, end="\n")

learntosurf/Baekjoon/12_BruteForce/1018.py

Lines changed: 0 additions & 27 deletions
This file was deleted.

learntosurf/Baekjoon/12_BruteForce/2798.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

learntosurf/Baekjoon/12_BruteForce/2839.py

Lines changed: 0 additions & 57 deletions
This file was deleted.

learntosurf/Baekjoon/1_Input_and_Arithmetic/1000.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

learntosurf/Baekjoon/1_Input_and_Arithmetic/10171.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

learntosurf/Baekjoon/1_Input_and_Arithmetic/2588.py

Lines changed: 0 additions & 38 deletions
This file was deleted.

learntosurf/Baekjoon/2_If/14881.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

learntosurf/Baekjoon/2_If/2525.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)