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

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

Perfect Skyline

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

요약
N개의 블록(N은 최대 15)을 S개의 건물에 나누어 배정해 각 건물의 블록 높이 합이 목표 높이와 정확히 일치하도록 만든다.
난이도

보통10점 중 7점

유형
백트래킹, 비트 연산
정답자
아직 제출이 없습니다

문제

Zara, an aspiring architect and urban planner, has drawn out what she considers to be the perfect skyline. As Zara is still aspiring she must use her young daughter, Pippa, to test out her designs. In order to test out the designs Pippa must build them out of her building blocks! The building blocks Pippa has have a uniform width and depth, but come in different heights hh. Zara's description for Pippa will consist of a list of buildings, each with a target height bb.

Pippa must then use some (not necessarily all) of her blocks to stack together such that the sum of the heights of the blocks in each stack corresponds to the height of the building in the skyline. Since Pippa prefers building instead of solving puzzles she wants you to determine how she must stack the blocks so that she must only do the stacking!

입력

The input consists of a single test case. The first line of this test case contains two integers N,SN,S (1≤N≤151 \le N \le 15 and 1≤S≤151 \le S \le 15), where NN is the number of blocks Pippa has and SS is the number of buildings in the skyline Zara made.  

The next line contains NN integers (1≤h_i≤1091 \le h\_i \le 10^{9}) representing the heights of each block.  The last line contains SS integers (1≤b_i≤1091 \le b\_i \le 10^{9}) representing the height of each building.

출력

If it is possible for Pippa to build Zara's skyline then output SS lines. On each line output a single number s_is\_i representing the number of blocks needed to build building ii where ii corresponds to the ithi^{\text{th}} building listed in the input.  This should be followed (on the same line) by s_is\_i numbers jj representing the blocks of the input used in building ii, where jj represents the jthj^{\text{th}} block appearing the input.  

If no combination of the blocks can build the desired skyline then output -1.

예제3

  1. 예제 1

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

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

    입력
    7 3
    5 4 3 6 1 2 2
    4 11 4
    
    예상 출력
    1 2
    2 1 4
    2 3 5