ps | |
---|---|
링크 | acmicpc.net/… |
출처 | BOJ |
문제 번호 | 7535 |
문제명 | A Bug’s Life |
레벨 | 골드 2 |
분류 |
이분 그래프 |
시간복잡도 | O(T*(V+E)) |
인풋사이즈 | T<=?, V<=2000, E<=1000000 |
사용한 언어 | Python |
제출기록 | 103500KB / 1780ms |
최고기록 | 1660ms |
해결날짜 | 2022/11/07 |
태그 |
"""Solution code for "BOJ 7535. A Bug’s Life".
- Problem link: https://www.acmicpc.net/problem/7535
- Solution link: http://www.teferi.net/ps/problems/boj/7535
Tags: [Bipartite Graph]
"""
import sys
from teflib import graph as tgraph
def main():
scenario_count = int(sys.stdin.readline())
for scenario_no in range(1, scenario_count + 1):
bug_count, interaction_count = [
int(x) for x in sys.stdin.readline().split()
]
graph = [[] for _ in range(bug_count)]
for _ in range(interaction_count):
u, v = [int(x) for x in sys.stdin.readline().split()]
graph[u - 1].append(v - 1)
graph[v - 1].append(u - 1)
print(f'Scenario #{scenario_no}:')
if tgraph.is_bipartite(graph):
print('No suspicious bugs found!')
else:
print('Suspicious bugs found!')
print()
if __name__ == '__main__':
main()