Interactive Array Guessing

시간 제한3초메모리 제한512 MB

요약
각각 10개 이하의 서로 다른 양의 정수로 이루어진 n개의 숨은 배열을, 여러 인덱스를 골라 물으면 구분자 없이 이어 붙인 내용을 돌려주는 질의만으로 알아내야 한다.
난이도

보통10점 중 7점

유형
완전 탐색, 구현, 수학, 그리디
정답자
아직 제출이 없습니다

문제

This is an interactive problem.

Jury has prepared n non-empty integer arrays a1, a2, . . . , an. Each array consists of at most 10 positive integers not exceeding 1000. The elements of each array are pairwise distinct.

You can make queries of the following kind: choose several indices q1, q2, . . . , qm, where 1 ≤ m ≤ n and 1 ≤ qi ≤ n. These indices do not have to be distinct. The testing system tells you the contents of arrays aq1, aq2, . . . , aqm in the same order. However, these contents are concatenated without any delimeters.

Your task is to find the contents of all n arrays.

예제1

  1. 예제 1

    입력
    3
    
    5 1 1 2 2 1
    
    4 1 2 1 1
    
    2 1 2
    
    
    예상 출력
    
    ? 3 1 2 3
    
    ? 3 1 3 1
    
    ? 1 2
    
    ! 1 1 2 1 2 2 2 1