CodeforcesRound#749(Div.1.2basedonTechnocup2022EliminationRound1)-D.Omkar and the Meaning of Life-题解

Posted Tisfy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeforcesRound#749(Div.1.2basedonTechnocup2022EliminationRound1)-D.Omkar and the Meaning of Life-题解相关的知识,希望对你有一定的参考价值。

Codeforces Round #749 (Div. 1 + Div. 2, based on Technocup 2022 Elimination Round 1) - D. Omkar and the Meaning of Life

传送门
Time Limit: 2 seconds
Memory Limit: 256 megabytes

Problem Description

It turns out that the meaning of life is a permutation p 1 , p 2 , … , p n p1,p2,…,pn p1,p2,,pn of the integers 1 , 2 , … , n ( 2 ≤ n ≤ 100 ) 1,2,…,n (2≤n≤100) 1,2,,n(2n100). Omkar, having created all life, knows this permutation, and will allow you to figure it out using some queries.

A query consists of an array a 1 , a 2 , … , a n a1,a2,…,an a1,a2,,an of integers between 1 1 1 and n n n. a is not required to be a permutation. Omkar will first compute the pairwise sum of a a a and p p p, meaning that he will compute an array s s s where s j = p j + a j s_j=p_j+a_j sj=pj+aj for all j = 1 , 2 , … , n j=1,2,…,n j=1,2,,n. Then, he will find the smallest index k k k such that sk occurs more than once in s s s, and answer with k k k. If there is no such index k k k, then he will answer with 0 0 0.

You can perform at most 2 n 2n 2n queries. Figure out the meaning of life p p p.

Interaction

Start the interaction by reading single integer n ( 2 ≤ n ≤ 100 ) n (2≤n≤100) n(2n100) — the length of the permutation p p p.

You can then make queries. A query consists of a single line “ ?   a 1   a 2   …   a n ?\\ a_1\\ a_2\\ …\\ a_n ? a1 a2  an ( 1 ≤ a j ≤ n ) (1≤a_j≤n) (1ajn).

The answer to each query will be a single integer k k k as described above ( 0 ≤ k ≤ n ) (0≤k≤n) (0kn).

After making a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:

fflush(stdout) or cout.flush() in C++;
System.out.flush() in Java;
flush(output) in Pascal;
stdout.flush() in Python;

see documentation for other languages.

To output your answer, print a single line “ !   a 1   a 2   …   a n !\\ a_1\\ a_2\\ …\\ a_n ! a1 a2  an” then terminate.

You can make at most 2 n 2n 2n queries. Outputting the answer does not count as a query.

Hack Format

To hack, first output a line containing n ( 2 ≤ n ≤ 100 ) n (2≤n≤100) n(2n100), then output another line containing the hidden permutation p 1 , p 2 , … , p n p_1,p_2,…,p_n p1,p2,,pn of numbers from 1 1 1 to n n n.

Sample Input

5

2

0

1

Sample Onput


? 4 4 2 3 2

? 3 5 1 5 5

? 5 2 4 3 1

! 3 2 1 5 4

Note

In the sample, the hidden permutation p p p is [ 3 , 2 , 1 , 5 , 4 ] [3,2,1,5,4] [3,2,1,5,4]. Three queries were made.

The first query is a = [ 4 , 4 , 2 , 3 , 2 ] a=[4,4,2,3,2] a=[4,4,2,3,2]. This yields s = [ 3 + 4 , 2 + 4 , 1 + 2 , 5 + 3 , 4 + 2 ] = [ 7 , 6 , 3 , 8 , 6 ] s=[3+4,2+4,1+2,5+3,4+2]=[7,6,3,8,6] s=[3+4,2+4,1+2,5+3,4+2]=[7,6,3,8,6]. 6 6 6 is the only number that appears more than once, and it appears first at index 2 2 2, making the answer to the query 2 2 2.

The second query is a = [ 3 , 5 , 1 , 5 , 5 ] a=[3,5,1,5,5] a=[3,5,1,5,5]. This yields s = [ 3 + 3 , 2 + 5 , 1 + 1 , 5 + 5 , 4 + 5 ] = [ 6 , 7 , 2 , 10 , 9 ] s=[3+3,2+5,1+1,5+5,4+5]=[6,7,2,10,9] s=[3+3,2+5,1+1,5+5,4+5]=[6,7,2,10,9]. There are no numbers that appear more than once here, so the answer to the query is 0.

The third query is a = [ 5 , 2 , 4 , 3 , 1 ] a=[5,2,4,3,1] a=[5,2,4,3,1]. This yields s = [ 3 + 5 , 2 + 2 , 1 + 4 , 5 + 3 , 4 + 1 ] = [ 8 , 4 , 5 , 8 , 5 ] s=[3+5,2+2,1+4,5+3,4+1]=[8,4,5,8,5] s=[3+5,2+2,1+4,5+3,4+1]=[8,4,5,8,5]. 5 5 5 and 8 8 8 both occur more than once here. 5 5 5 first appears at index 3 3 3, while 8 8 8 first appears at index 1 1 1, and 1 < 3 1<3 1<3, making the answer to the query 1 1 1.

Note that the sample is only meant to provide an example of how the interaction works; it is not guaranteed that the above queries represent a correct strategy with which to determine the answer.


题目大意

给你一个 n n n,这组数据其实是隐藏了 n n n的一个全排列。你可以进行最多 2 n 2n 2n次询问,每次输入一个新的序列,让隐藏的序列一一对应临时加上这个新的序列,之后把有相同的值的元素中,最小的下标返回给你。

让你通过询问,得出隐藏的序列。

比如样例隐藏了序列 [ 3 , 2 , 1 , 5 , 4 ] [3,2,1,5,4] [3,2,1,5,4],你进行了一次询问并让隐藏序列一一对应地临时加上你给的序列 [ 4 , 4 , 2 , 3 , 2 ] [4,4,2,3,2] [4,4,2,3,2]. 那么相加产生的临时序列是 [ 3 + 4 , 2 + 4 , 1 + 2 , 5 + 3 , 4 + 2 ] = [ 7 , 6 , 3 , 8 , 6 ] [3+4,2+4,1+2,5+3,4+2]=[7,6,3,8,6] [3+4,2+4,1+2,5+3,4+2]=[7,6,3,8,6]. 6 6 6 不只一个,所有有相同值的元素集合是: [ 第 2 个 元 素 , 第 5 个 元 素 ] [第2个元素,第5个元素] [25],其中下标最小的是第二个元素,它的下标是CodeforcesRound#749(Div.1.2basedonTechnocup2022EliminationRound1)-D.Omkar and the Meaning of Life-题解

Codeforces Round #749(Div. 1+Div. 2, based on Technocup 2022 Elimination Round1)-A. Windblume Ode-题解

补题日记CF#749 Div.1+ Div.2

Codeforces Round #749 (Div. 1 + Div. 2, based on Technocup 2022 Elimination Round 1) ABCD解题报告

Codeforces Round #749 (Div. 1 + Div. 2, based on Technocup 2022 Elimination Round 1) ABCD解题报告

Codeforces Round #749 (Div. 1 + Div. 2, based on Technocup 2022 Elimination Round 1) ABCD解题报告