728x90
문제:www.acmicpc.net/problem/1707
비고:
-dfs로 돌면서 label(dictionary)를 잡고 돌고
-이웃node가 label이 없으면 이전 nodes' label과 반대로 달고
-새로운 node마다 labeled 이웃 전체(이전 node를 지우고하는게 아니라)에 대해 label이 같은지 테스트가 관건
-난이도 중
내소스코드:
boj.kr/79b09fa7f4294aa19104a5d58d317c05
공유 소스 보기
import itertools import sys sys.setrecursionlimit(99999) test_case = int(sys.stdin.readline().strip()[0]) data = (list(map(int, x.strip().split())) for x in sys.stdin.readlines()) def trans(x): return -x def dfs(x, adj_, chk_, label_, prev_, res): chk_[x]
www.acmicpc.net
728x90
'CS' 카테고리의 다른 글
[Algorithm]백준, 1912, 연속합 (0) | 2020.10.14 |
---|---|
[Algorithm]백준, 2630, 색종이 만들기 (0) | 2020.10.12 |
[Algorithm]백준, 1931, 회의실배정 (0) | 2020.10.10 |
[Algorithm]백준, 12845, 모두의 마블 (0) | 2020.10.10 |
[Algorithm]백준, 11047, 동전 0 (0) | 2020.10.10 |