0% found this document useful (0 votes)
87 views1 page

Interactive Permutation Guessing: Interaction Protocol

You must interactively guess a hidden permutation of size n by querying permutations and receiving the length of the longest common subsequence between your query and the hidden permutation. You are allowed to make at most 5n^2 queries, outputting a permutation on each line and reading the response. The goal is to use these queries to deduce the hidden permutation.

Uploaded by

Tú Ân
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views1 page

Interactive Permutation Guessing: Interaction Protocol

You must interactively guess a hidden permutation of size n by querying permutations and receiving the length of the longest common subsequence between your query and the hidden permutation. You are allowed to make at most 5n^2 queries, outputting a permutation on each line and reading the response. The goal is to use these queries to deduce the hidden permutation.

Uploaded by

Tú Ân
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1552 Interactive Permutation Guessing

There is a permutation a of size n that you have to guess interactively.


You are allowed to make queries of the following kind. You output any permutation b of size n. The
information given back to you is the length of the longest common subsequence of permutations a and
b.
Interaction protocol
First, your program must read from the standard input one line with integer n, the size of the
permutation you have to guess.
Your program must then write to the standard output one line with a permutation and wait for a
line in the standard input with a response, then write next query and read next response, and so on
until you know a.
Once you receive response n (which means youve found a), youre done and your program must
exit.

Input
The first line of the standard input contains integer n, the size of the permutation (1 n 40).
Each of the next lines of the standard input contains response to your query the length of the
longest common subsequence of the permutation queried by you and the permutation a.

Output
Each line of the standard output should contain a space-separated list of integers that form a permu-
tation youre querying.
Your can make at most 5n2 queries.
You must flush the standard output after printing each line. You must not print any lines after you
receive the response n, just exit.

Sample Input
4
3
2
2
4

Sample Output
1 2 3 4
1 3 4 2
4 1 2 3
3 1 2 4

You might also like