This file contains hidden or 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
from collections import deque | |
import copy | |
n = int(input()) | |
graph = [[] for _ in range(n+1)] | |
time = [0] *(n+1) | |
indegree = [0]*(n+1) | |
for i in range(1,n+1): |
This file contains hidden or 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
def find_parent(parent, x): | |
if parent[x] != x: | |
parent[x] = find_parent(parent, parent[x]) | |
return parent[x] | |
def union_parent(parent, a, b): | |
a = find_parent(parent, a) | |
b = find_parent(parent, b) | |
if a < b: |
This file contains hidden or 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
def find_parent(parent, x): | |
if parent[x] != x: | |
parent[x] = find_parent(parent, parent[x]) | |
return parent[x] | |
def union_parent(parent, a, b): | |
a = find_parent(parent, a) | |
b = find_parent(parent, b) | |
if a<b: | |
parent[b] = a |
This file contains hidden or 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
from collections import deque | |
v,e = map(int, input().split()) | |
indegree = [0] * (v+1) | |
graph = [[] for i in range(v+1)] | |
for _ in range(e): | |
a,b = map(int, input().split()) | |
graph[a].append(b) |
This file contains hidden or 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
def find_parent(parent, x): | |
if parent[x] != x: | |
parent[x] = find_parent(parent,parent[x]) | |
return parent[x] | |
def union_parent(parent, a, b): | |
a = find_parent(parent,a) | |
b = find_parent(parent,b) |
This file contains hidden or 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
def find_parent(parent, x): | |
if parent[x] != x: | |
parent[x] = find_parent(parent, parent[x]) | |
return parent[x] | |
def union_parent(parent, a, b): | |
a = find_parent(parent,a) | |
b = find_parent(parent, b) |
This file contains hidden or 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
def find_parent(parent, x): | |
if parent[x] != x: | |
parent[x] = find_parent(parent,parent[x]) | |
return parent[x] | |
def union_parent(parent, a, b): | |
a = find_parent(parent,a) | |
b= find_parent(parent,b) | |
if a<b: | |
parent[b] = a |
This file contains hidden or 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
def find_parent(parent, x): | |
if parent[x] != x: | |
return find_parent(parent, parent[x]) | |
return x | |
def union_parent(parent, a, b): | |
a = find_parent(parent,a) | |
b = find_parent(parent,b) | |
if a<b: | |
parent[b] = a |
This file contains hidden or 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
import heapq | |
import sys | |
input = sys.stdin.readline | |
INF = int(1e9) | |
n, m, c = map(int, input().split()) | |
graph = [[] for _ in range(n+1)] | |
start = c | |
distance = [INF]*(n+1) |
This file contains hidden or 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
n, m = map(int, input().split()) | |
INF = int(1e9) | |
graph = [[INF]*(n+1) for _ in range(n+1)] | |
for i in range(1, n+1): | |
graph[i][i] = 0 | |
for i in range(m): |
NewerOlder