Kitchens of Königsberg

시간 제한8초메모리 제한1024 MB

요약
무향 다중 그래프에서 정확히 k개의 간선이 닿도록 정점 부분집합을 고르거나 불가능을 보고한다.
난이도

보통10점 중 7점

유형
그래프, 동적 계획법, 수학, 조합론
정답자
아직 제출이 없습니다

문제

The year is 17641764 (or 900900 in base-1414). During the past few decades, the bridges of Königsberg have become a major attraction for combinatorics tourism from all over the world. In a recent travel brochure, your predecessor on the Königsberg Board of Tourism has promised the existence of kk Bridges Alongside Palatable Cuisine, where hungry graph theorists can combine their intellectual and culinary pursuits by finishing their pilgrimage with a delicious bowl of traditional meatballs from a charming street kitchen. Alas, none of these kitchens have actually been built, so this will be your first task!

Naturally, you begin by modelling Königsberg as an undirected multigraph. Rivers divide the city into areas, which you model as vertices, and the bridges become the edges. With this abstraction, you start to investigate whether it is possible to select areas to place kitchens in, so that exactly kk bridges end in an area with a kitchen. As an example, consider the first sample case, shown in Figure K.1.

Figure K.1: Visualization of the first sample case. If kitchens are placed at areas AA and BB, then the 66 bridges aa, bb, cc, dd, ee, and ff are serviced. Another solution would be to place kitchens at BB and CC.

Modified from Solutio problematis ad geometriam situs pertinentis by Leonhard Euler

입력

The input consists of:

  • One line with three integers nn, mm, and kk (1≤n≤50001 \leq n \leq 5000, 0≤m≤50,0000 \leq m \leq 50\\,000, 1≤k≤61 \leq k \leq 6), the number of areas, the number of bridges, and the number of bridges that must end in an area with a kitchen.
  • mm lines, each with two integers aa and bb (1≤a<b≤n1 \leq a < b \leq n), indicating a bridge between areas aa and bb. Note that there can be multiple bridges between the same pair of areas.

출력

If there is a subset of areas in which kitchens can be placed, so that exactly kk bridges end in an area with a kitchen, output the number of areas in this subset, followed by these areas. Otherwise, output "impossible".

If there are multiple valid solutions, you may output any one of them.

예제5

  1. 예제 1

    입력
    4 7 6
    1 2
    1 2
    1 3
    1 3
    1 4
    2 4
    3 4
    
    예상 출력
    2
    1 2
    
  2. 예제 2

    입력
    7 9 5
    1 2
    2 3
    1 3
    1 4
    4 5
    1 5
    1 6
    6 7
    1 7
    
    예상 출력
    3
    4 2 3
    
  3. 예제 3

    입력
    8 7 6
    1 2
    1 3
    1 4
    1 5
    1 6
    1 7
    1 8
    
    예상 출력
    6
    8 7 6 4 3 2
    
  4. 예제 4

    입력
    5000 0 1
    
    예상 출력
    impossible
    
  5. 예제 5

    입력
    4 6 2
    1 2
    1 3
    1 4
    2 3
    2 4
    3 4
    
    예상 출력
    impossible