사용자 도구

사이트 도구


ps:problems:boj:15783

세진 바이러스

ps
링크acmicpc.net/…
출처BOJ
문제 번호15783
문제명세진 바이러스
레벨플래티넘 4
분류

SCC

시간복잡도O(V+E)
인풋사이즈V<=100,000, E<=100,000
사용한 언어Python
제출기록73088KB / 448ms
최고기록352ms
해결날짜2022/11/17

풀이

코드

"""Solution code for "BOJ 15783. 세진 바이러스".

- Problem link: https://www.acmicpc.net/problem/15783
- Solution link: http://www.teferi.net/ps/problems/boj/15783

Tags: [SCC]
"""

import itertools
import sys
from teflib import graph as tgraph


def main():
    N, M = [int(x) for x in sys.stdin.readline().split()]
    graph = [[] for _ in range(N)]
    for _ in range(M):
        A, B = [int(x) for x in sys.stdin.readline().split()]
        graph[A].append(B)

    scc_graph, *_ = tgraph.condensation_graph(graph)
    answer = len(scc_graph) - len(set(itertools.chain.from_iterable(scc_graph)))
    print(answer)


if __name__ == '__main__':
    main()

토론

댓글을 입력하세요:
W᠎ Q V X U
 
ps/problems/boj/15783.txt · 마지막으로 수정됨: 2022/11/17 03:13 저자 teferi