From 5757eec58232afc81f6bd8f531436443dc17e91c Mon Sep 17 00:00:00 2001 From: Github Date: Tue, 14 Nov 2023 16:55:11 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[BOJ]=20/=20=EB=85=B9=EC=83=89=20=EC=98=B7?= =?UTF-8?q?=20=EC=9E=85=EC=9D=80=20=EC=95=A0=EA=B0=80=20=EC=A0=A4=EB=8B=A4?= =?UTF-8?q?=EC=A7=80=3F=20/=20gold=204=20/=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../6\354\243\274\354\260\250/[BOJ] 4485.py" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "\353\257\274\354\236\245\352\267\234/6\354\243\274\354\260\250/[BOJ] 4485.py" diff --git "a/\353\257\274\354\236\245\352\267\234/6\354\243\274\354\260\250/[BOJ] 4485.py" "b/\353\257\274\354\236\245\352\267\234/6\354\243\274\354\260\250/[BOJ] 4485.py" new file mode 100644 index 0000000..7773ae7 --- /dev/null +++ "b/\353\257\274\354\236\245\352\267\234/6\354\243\274\354\260\250/[BOJ] 4485.py" @@ -0,0 +1,22 @@ +INF = 1000000 + +N = int(input()) +cost = [] +for _ in range(N) : + cost.extend(list(map(int, input().split()))) +node = [[0 for _ in range(N*N)] for _ in range(N*N)] + +for end in range(N*N) : + if end == 0 : + continue + elif end % N == 0 : + node[end-N][end] = cost[end] + node[end][end-N] = cost[end] + elif end < N : + node[end-1][end] = cost[end] + node[end][end-1] = cost[end] + else : + node[end-N][end] = cost[end] + node[end][end-N] = cost[end] + node[end-1][end] = cost[end] + node[end][end-1] = cost[end] \ No newline at end of file From 83f9211d29ef9dc63f628422249a5355116e935e Mon Sep 17 00:00:00 2001 From: Github Date: Tue, 14 Nov 2023 16:55:43 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[BOJ]=20/=20=ED=83=80=EC=9E=84=EB=A8=B8?= =?UTF-8?q?=EC=8B=A0=20/=20gold=204=20/=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../6\354\243\274\354\260\250/[BOJ] 11657.py" | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 "\353\257\274\354\236\245\352\267\234/6\354\243\274\354\260\250/[BOJ] 11657.py" diff --git "a/\353\257\274\354\236\245\352\267\234/6\354\243\274\354\260\250/[BOJ] 11657.py" "b/\353\257\274\354\236\245\352\267\234/6\354\243\274\354\260\250/[BOJ] 11657.py" new file mode 100644 index 0000000..6e38582 --- /dev/null +++ "b/\353\257\274\354\236\245\352\267\234/6\354\243\274\354\260\250/[BOJ] 11657.py" @@ -0,0 +1,41 @@ +import sys +input = sys.stdin.readline + +INF = float("inf") +V, E = map(int, input().split()) +dis = [INF for _ in range(V)] +dis[0] = 0 + +edge = [] +for _ in range(E) : + edge.append(list(map(int, input().split()))) + +circle = [] +for i in range(V) : + for e in edge : + start = e[0] - 1 + end = e[1] - 1 + cost = e[2] + + if dis[start] + cost < dis[end] : + dis[end] = dis[start] + cost + + if i == V - 1 : + for e in edge : + start = e[0] - 1 + end = e[1] - 1 + cost = e[2] + + if dis[start] + cost < dis[end] : + circle.append(end) + dis[end] = dis[start] + cost + +if len(circle) != 0 : + print(-1) + exit() + +for i in dis[1:] : + if i == INF : + print(-1) + else : + print(i) \ No newline at end of file From 75feeb265829c87ae047a2f445b0a2aa3d054367 Mon Sep 17 00:00:00 2001 From: Github Date: Tue, 14 Nov 2023 16:56:31 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[PRGMS]=20/=20=EC=88=9C=EC=9C=84=20/=20leve?= =?UTF-8?q?l=203=20/=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../[PRGMS] 49191.py" | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 "\353\257\274\354\236\245\352\267\234/6\354\243\274\354\260\250/[PRGMS] 49191.py" diff --git "a/\353\257\274\354\236\245\352\267\234/6\354\243\274\354\260\250/[PRGMS] 49191.py" "b/\353\257\274\354\236\245\352\267\234/6\354\243\274\354\260\250/[PRGMS] 49191.py" new file mode 100644 index 0000000..159f8d0 --- /dev/null +++ "b/\353\257\274\354\236\245\352\267\234/6\354\243\274\354\260\250/[PRGMS] 49191.py" @@ -0,0 +1,28 @@ +def solution(n, results): + answer = 0 + INF = 1000000 + + rank = [[INF for _ in range(n)] for _ in range(n)] + for i in range(n) : + rank[i][i] = 0 + + for i in results : + win = i[0] - 1 + lose = i[1] - 1 + rank[win][lose] = 1 + + for k in range(n) : + for i in range(n) : + for j in range(n) : + rank[i][j] = min(rank[i][j], rank[i][k] + rank[k][j]) + + for i in range(n) : + canRank = True + for j in range(n) : + if rank[i][j] == INF and rank[j][i] == INF : + canRank = False + break + if canRank : + answer += 1 + + return answer \ No newline at end of file