Submission #16587305


Source Code Expand

Copy
import sys

sys.path.append("/home/contestant/.local/lib/python3.8/site-packages")

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 PyPy3 (7.3.0)
Score 100
Code Size 632 Byte
Status AC
Exec Time 4405 ms
Memory 685576 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 1
AC × 11
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 813 ms 116904 KB
max_random_00 AC 4264 ms 676704 KB
max_random_01 AC 4337 ms 677652 KB
max_random_02 AC 4389 ms 685576 KB
max_random_03 AC 4405 ms 685284 KB
max_random_04 AC 4387 ms 668036 KB
random_00 AC 3926 ms 602848 KB
random_01 AC 4058 ms 667024 KB
random_02 AC 1808 ms 235216 KB
random_03 AC 2083 ms 439848 KB
random_04 AC 1985 ms 366300 KB