문제 링크
- http://icpc.me/16046
문제 출처
- 2018 NAIPC G번
사용 알고리즘
- Matroid Intersection
풀이
무향 연결 그래프 G(V,E)에서 IG={I:I⊂E,E∖I can connects all vertex in G}라고 정의하면 M=(S,IG)는 Matroid입니다.
$\mathcal{I}{G}’ = \lbrace I : I \subset E, E\setminus I\text{ can connects all vertex in } G \text{ using edge colored with R or G} \rbrace,\mathcal{I}{G}’’ = \lbrace I : I \subset E, E\setminus I\text{ can connects all vertex in } G \text{ using edge colored with G or B} \rbrace라고정의합시다.\mathcal{M}’ = (S, \mathcal{I}_G’)와\mathcal{M}’’ = (S, \mathcal{I}_G’’)$ 역시 Matroid입니다.
그러므로 M′과 M′‘의 Cardinality가 K인 Maximum Weight Common Independent Set을 구하면 됩니다.
전체 코드
1 |
|