포럼
문제 ICPC00158 ⇄ 인터랙티브

B. Boredom Buster

설명

You are stuck alone in a cabin and it is raining outside. You are bored out of your mind and the only available boredom buster is a deck of Memory cards. Playing Memory by yourself is not very fun, but you developed a single player variant that requires not only good memory but also strategy.

It goes like this: You have a shuffled deck of \(n\) cards, where \(n\) is even and each card contains a number from \(1\) to \(n/2\). There are exactly two cards of each number. The cards are laid face down on the table and your goal is to find what number is written on each of them. In one move, you pick up two cards. Before revealing them, you randomly shuffle them so that you do not know which card was where. Then you look at the two cards. After that, you shuffle them again face down before you put them back where they were. That way, you know the numbers of the two cards and where they are, but not which card ended up where, or even what card came from which spot initially.

Your task is to write a program that will beat this game.

Interaction This is an interactive problem. Your submission will be run against an interactor, which reads the standard output of your submission and writes to the standard input of your submission. This interaction needs to follow a specific protocol:
- The interactor first sends an integer \(n\) (\(2 \leq n \leq 10^5\), \(n\) is even). The only time \(n\) is not equal to \(10^5\) is in the sample.
- Your submission then repeatedly sends two integers \(x\) and \(y\) (\(1 \leq x, y \leq n\), \(x \neq y\)) preceded by "?".
- The interactor replies with two integers \(a\) and \(b\) (\(1 \leq a, b \leq n/2\)), indicating that after the query either the \(x\)th card is \(a\) and the \(y\)th card is \(b\), or the \(x\)th card is \(b\) and the \(y\)th card is \(a\).
- When you are ready to print the answer, print "!" followed by \(n\) integers \(a_1, a_2, \ldots, a_n\), where \(a_i\) is the number of the \(i\)th card at the time of writing.

You may use at most \(92\,000\) moves. Printing the answer does not count as a move.

The interactor is not adaptive. Initial positions of the cards are determined by the interactor before any interaction takes place. When you make a move the two cards will be shuffled uniformly randomly by the interactor both before being shown to you and before being placed back down. The initial layout of the cards is guaranteed to be a random permutation of \(1, 1, 2, 2, \dots, n/2, n/2\).

Your submission will be run on exactly \(100\) test cases, each of which will have \(n = 10^5\).

Make sure you flush the buffer after each write.

A testing tool is provided to help you develop your solution.

Interaction

제약
입력 형식
출력 형식
인터랙티브 문제
프로그램이 고정된 입력을 읽는 대신 표준 입출력으로 채점기와 메시지를 주고받습니다. 한 줄을 출력할 때마다 표준 출력을 flush하고(예: cout에 endl / print(..., flush=True) / System.out.flush()), 채점기의 응답을 읽으세요. 파일을 읽거나 쓰면 안 됩니다.
예제 1
입력
12324
6
3 2 2 1 3 1
출력
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NWERC 2021

평가 및 의견

B. Boredom Buster

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

B. Boredom Buster

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8