Conflict

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

요약
건물의 전원을 하나씩 끊으면서 끊는 시점에 아직 전원이 살아 있는 이웃과 연결된 도로 수를 보고받아, 최대 N-1번의 질의로 다중 그래프의 모든 간선을 알아내는 인터랙티브 문제이다.
난이도

보통10점 중 7점

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

문제

In a desperate conflict, with a ruthless enemy...

This is an interactive problem.

As an elite spy fighting against a great evil empire, you have been tasked with TT separate reconnaissance missions. Each mission takes place in a different city of the empire, and your success is crucial to the resistance.

Every city is represented by NN key buildings, numbered from 11 to NN, connected by a network of roads. Each road connects two different buildings, and there may be multiple roads between the same pair of buildings. Your objective for each mission is to fully reconstruct the city's road network.

To achieve this, you are equipped with a special device capable of performing a sequential shutdown of the city's power grid. You can define a shutdown sequence p_1,p_2,…,p_Np\_1, p\_2, \dots, p\_N --- a permutation of all NN buildings. At the exact moment when the power to building p_ip\_i is cut, the device reports the number of roads that connect p_ip\_i to other buildings that still have power.

You are allowed to use this device at most N−1N-1 times during each mission.

제한

  • 1≤T≤1,0001 \le T \le 1\\,000
  • 2≤N≤1,0002 \le N \le 1\\,000
  • 0≤M≤1040 \le M \le 10^4
  • The sum of NN over all test cases is at most 2,0002\\,000.
  • The sum of MM over all test cases is at most 10410^4.

힌트

After printing each query, you must flush the output buffer to ensure the interactor receives your output. Failing to do so can result in an unexpected verdict. You can flush the output by using the following methods:

  • In C++, call fflush(stdout) or cout.flush().
  • In Java, call System.out.flush().
  • In Python, call sys.stdout.flush().
  • In Kotlin, call System.out.flush().

For other languages, you should refer to the official documentation for your language.

예제1

  1. 예제 1

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