====== 이분 그래프 ====== ===== 풀이 ===== * 그래프가 [[ps:그래프#특수한 그래프|이분 그래프]]인지만 판별하면 되는 기본 문제. 시간복잡도는 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:teflib:graph#create_graph_from_input|teflib.graph.create_graph_from_input]] * [[:ps:teflib:graph#two_coloring|teflib.graph.two_coloring]] {{tag>BOJ ps:problems:boj:골드_4}}