ps:problems:boj:1707
이분 그래프
| ps | |
|---|---|
| 링크 | acmicpc.net/… |
| 출처 | BOJ |
| 문제 번호 | 1707 |
| 문제명 | 이분 그래프 |
| 레벨 | 골드 4 |
| 분류 |
이분 그래프 |
| 시간복잡도 | O(T*(V+E)) |
| 인풋사이즈 | T<=5, V<=20,000, E<=200,000 |
| 사용한 언어 | Python |
| 제출기록 | 69428KB / 1204ms |
| 최고기록 | 1000ms |
| 해결날짜 | 2023/04/04 |
풀이
- 그래프가 이분 그래프인지만 판별하면 되는 기본 문제. 시간복잡도는 O(V+E)
코드
"""Solution code for "BOJ 1707. 이분 그래프".
- Problem link: https://www.acmicpc.net/problem/1707
- Solution link: http://www.teferi.net/ps/problems/boj/1707
"""
import sys
from teflib import graph as tgraph
def main():
K = int(sys.stdin.readline())
for _ in range(K):
V, E = [int(x) for x in sys.stdin.readline().split()]
graph = tgraph.create_graph_from_input(V, E)
try:
tgraph.two_coloring(graph)
print('YES')
except ValueError:
print('NO')
if __name__ == '__main__':
main()
- Dependency:
ps/problems/boj/1707.txt · 마지막으로 수정됨: 2023/04/04 14:54 저자 teferi

토론