Logo
(追記) (追記ここまで)

19331번 - Compressed Spanning Subtrees 다국어인터랙티브

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB19101058.824%

문제

For a tree $T$ consisting of $n$ vertices numbered from 1ドル$ to $n,ドル the compressed spanning subtree $S(X)$ of a set $X$ of spanned vertices (vertices that are not in $X$ are called not spanned) can be defined by the following algorithm:

  1. Assign $S(X) \leftarrow T$;
  2. If there is any not spanned vertex that has exactly one edge incident to it, remove it along with the edge;
  3. Repeat step 2ドル$ while its condition stays true;
  4. If there is any not spanned vertex that has exactly two edges incident to it, remove it along with the edges and add a new edge connecting the two remaining endpoints of the removed edges;
  5. Repeat step 4ドル$ while its condition stays true.

Formally, $S(X)$ is the smallest subgraph of $T$ containing all vertices in $X$ and then having all other vertices of degree two or less smoothed out.

The tree from test 1ドル,ドル and its compressed spanning subtrees for $X = {3, 4, 6}$ and for $X = {2, 5, 6}$.

You are not given the tree $T$. Instead, your task is to find it. You can ask questions of the following form: "How many vertices does the compressed spanning subtree of $X$ contain?". And since otherwise finding the tree by asking such questions would be impossible, there are no vertices incident to exactly two edges in $T$.

입력

출력

제한

프로토콜

The first line of input contains a single integer $n$ (2ドル \le n \le 100$).

Your program can ask a question by printing a line in the format "? $k$ $x_1$ $x_2$ $\ldots$ $x_k$" where integer $k$ (1ドル \le k \le n$) equals to the number of vertices in $X$ and distinct integers $x_i$ (1ドル \le x_i \le n$) represent these vertices in any order. You can ask no more than 2550ドル$ questions.

The answer for such question is an integer given on a separate line: the number of vertices in the compressed spanning subtree in question.

After asking sufficient questions, your program must give the answer by printing a line in the format "! $p_2$ $p_3$ $\ldots$ $p_n$". Here, considering $T$ as a rooted tree with root at vertex 1ドル,ドル $p_i$ must be the parent vertex of vertex $i$. After giving the answer, the program must immediately terminate gracefully.

예제 입력 1

6
3
4
4

예제 출력 1

? 3 4 3 6
? 4 1 2 3 6
? 3 2 5 6
! 1 2 2 3 3

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2018 > Day 8: Saratov SU Contest H번

Contest > Open Cup > 2017/2018 Season > Stage 13: Grand Prix of Saratov H번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /