Submission #16587319


Source Code Expand

Copy
import networkx as nx

import io
import os


input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
N, M = [int(x) for x in input().split()]
edges = [[int(x) for x in input().split()] for i in range(M)]

# Will WA if you don't include nodes with no in/outdegrees
graph = nx.DiGraph()
for i in range(N):
    graph.add_node(i)
for u, v in edges:
    graph.add_edge(u, v)


SCC = list(nx.algorithms.components.strongly_connected_components(graph))
print(len(SCC))
for comp in reversed(SCC):
    print(len(comp), *comp)

Submission Info

Submission Time
Task G - SCC
User atf
Language Python (3.8.2)
Score 0
Code Size 544 Byte
Status TLE
Exec Time 5534 ms
Memory 793384 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 1
AC × 4
TLE × 7
Set Name Test Cases
Sample example_00
All example_00, max_random_00, max_random_01, max_random_02, max_random_03, max_random_04, random_00, random_01, random_02, random_03, random_04
Case Name Status Exec Time Memory
example_00 AC 330 ms 52876 KB
max_random_00 TLE 5534 ms 766360 KB
max_random_01 TLE 5534 ms 764640 KB
max_random_02 TLE 5533 ms 764228 KB
max_random_03 TLE 5533 ms 764264 KB
max_random_04 TLE 5533 ms 764308 KB
random_00 TLE 5533 ms 759768 KB
random_01 TLE 5534 ms 793384 KB
random_02 AC 2684 ms 283924 KB
random_03 AC 3634 ms 625620 KB
random_04 AC 3333 ms 434428 KB