아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Birthday

시간 제한7초메모리 제한256 MB

요약
무방향 그래프의 정점을 k개의 비어 있지 않은 순서 있는 부분으로 나누되, 모든 간선의 양 끝이 같은 부분이나 이웃한 두 부분에 속하도록 해야 한다.
난이도

보통10점 중 7점

유형
그래프, 그리디, 구현
정답자
아직 제출이 없습니다

문제

Malvina wants to give Buratino a birthday present --- an undirected graph G=(V,E)G = (V, E). Buratino is turning kk, and Malvina wants to reflect this date in the graph by splitting it into kk parts, that is, by presenting the set of nodes of the graph VV as kk pairwise disjoint subsets V_1V\_1, V_2V\_2, …\ldots, V_kV\_k. Naturally, in this partition, all of the subsets V_iV\_i must be non-empty.

To demonstrate the connection between the past kk years, Malvina wants to split the graph in such a manner that for each of the edges uvuv, its end nodes uu and vv belonged to either the same or two adjacent subsets. Only subsets V_iV\_i and V_i+1V\_{i+1} are adjacent for every i=1,2,…k−1i = 1, 2, \ldots k-1.

입력

The first line of the input file contains two space-separated numbers NN and kk --- the number of nodes in the graph (11 ≤\le NN ≤\le 2,0002\\,000) and the number of parts (11 ≤\le kk ≤\le 2,0002\\,000) that the graph must be divided into.

The graph is defined in an adjacency matrix GG. The following NN lines of the file each contain NN symbols. The jjth symbol of the iith line equals '1' if there is an edge between the nodes ii and jj, and '0' if there is no edge between these nodes. It is guaranteed that the matrix is symmetrical (g_i,jg\_{i, j} = g_j,ig\_{j, i}), and that the matrix diagonal only contains zeroes (g_i,ig\_{i, i} = 00).

출력

In the first line of the output file, print "Yep", if the graph can be split into kk parts in the desired manner. Next, print kk lines. The iith line (ii = 11, 22, …\ldots, kk) contains the description of the iith part: first, print the number of nodes in V_iV\_i, next print the indices of the nodes belonging to V_iV\_i, separated by spaces, numbered in the same order as in the input data. If there are several ways of splitting the graph, print any one of them.

If it is impossible to split the graph into kk parts in the desired way, print "Nope".

예제2

  1. 예제 1

    입력
    4 3
    0110
    1010
    1101
    0010
    
    예상 출력
    Yep
    1 2
    2 1 3
    1 4
    
  2. 예제 2

    입력
    3 3
    011
    101
    110
    
    예상 출력
    Nope