Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
This is an interactive problem. Jury has hidden a permutation p of integers from 0 to n - 1 . You know only the length n . Remind that in permutation all integers are distinct. Let b be the inverse permutation for p , i.e. p b i = i for all i . The only thing you can do is to ask xor of elements p i and b j , printing two indices i and j (not necessarily distinct). As a result of the query with indices i and j you'll get the value , where denotes the xor operation. You can find the description of xor operation in notes. Note that some permutations can remain indistinguishable from the hidden one, even if you make all possible n 2 queries. You have to compute the number of permutations indistinguishable from the hidden one, and print one of such permutations, making no more than 2 n queries. The hidden permutation does not depend on your queries. The first line contains single integer n ( 1 ≤ n ≤ 5000 ) — the length of the hidden permutation. You should read this integer first. When your program is ready to print the answer, print three lines. In the first line print " ! ". In the second line print single integer answers _ cnt — the number of permutations indistinguishable from the hidden one, including the hidden one. In the third line print n integers p 0 , p 1 , ..., p n - 1 ( 0 ≤ p i < n , all p i should be distinct) — one of the permutations indistinguishable from the hidden one. Your program should terminate after printing the answer. To ask about xor of two elements, print a string " ? i j ", where i and j — are integers from 0 to n - 1 — the index of the permutation element and the index of the inverse permutation element you want to know the xor -sum for. After that print a line break and make flush operation. After printing the query your program should read single integer — the value of . For a permutation of length n your program should make no more than 2 n queries about xor -sum. Note that printing answer doesn't count as a query. Note that yo |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
31665345 |
Minimax |
D |
Oct. 24, 2017, 12:40 a.m. |
OK |
GNU C |
TESTS |
46 |
93 |
1945600 |
|
2100 |
|
31664791 |
Minimax |
D |
Oct. 23, 2017, 11:51 p.m. |
OK |
GNU C |
TESTS |
46 |
124 |
1945600 |
|
2100 |
|
34794465 |
luogu_bot3 |
D |
Feb. 1, 2018, 7:59 a.m. |
OK |
GNU C++ |
TESTS |
46 |
77 |
1945600 |
|
2100 |
|
31542895 |
eager |
D |
Oct. 20, 2017, 6:26 p.m. |
OK |
GNU C++ |
TESTS |
46 |
77 |
2150400 |
|
2100 |
|
31465615 |
Icyfox |
D |
Oct. 18, 2017, 12:20 a.m. |
OK |
GNU C++ |
TESTS |
46 |
77 |
2150400 |
|
2100 |
|
31364658 |
gjghfd |
D |
Oct. 15, 2017, 12:27 p.m. |
OK |
GNU C++ |
TESTS |
46 |
93 |
2150400 |
|
2100 |
|
31364541 |
gjghfd |
D |
Oct. 15, 2017, 12:24 p.m. |
OK |
GNU C++ |
TESTS |
46 |
93 |
2150400 |
|
2100 |
|
31554255 |
Canoeing |
D |
Oct. 21, 2017, 6:55 a.m. |
OK |
GNU C++ |
TESTS |
46 |
108 |
2252800 |
|
2100 |
|
31379088 |
vjudge3 |
D |
Oct. 15, 2017, 11:49 p.m. |
OK |
GNU C++ |
TESTS |
46 |
108 |
103526400 |
|
2100 |
|
31363451 |
AgReB |
D |
Oct. 15, 2017, 11:56 a.m. |
OK |
GNU C++ |
TESTS |
46 |
109 |
2252800 |
|
2100 |
|
31362511 |
zhan8855 |
D |
Oct. 15, 2017, 11:35 a.m. |
OK |
GNU C++ |
TESTS |
46 |
124 |
2048000 |
|
2100 |
|
31581432 |
shyf1301 |
D |
Oct. 21, 2017, 4:55 p.m. |
OK |
GNU C++ |
TESTS |
46 |
124 |
2252800 |
|
2100 |
|
31370886 |
f2lk6wf90d |
D |
Oct. 15, 2017, 3:33 p.m. |
OK |
GNU C11 |
TESTS |
46 |
140 |
1945600 |
|
2100 |
|
31376131 |
dragonslayerintraining |
D |
Oct. 15, 2017, 7:24 p.m. |
OK |
GNU C++11 |
TESTS |
46 |
61 |
1945600 |
|
2100 |
|
64075884 |
DepletedPrism |
D |
Nov. 2, 2019, 8:47 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
93 |
0 |
|
2100 |
|
31375846 |
neerajbattan |
D |
Oct. 15, 2017, 7:06 p.m. |
OK |
GNU C++11 |
TESTS |
46 |
93 |
2150400 |
|
2100 |
|
31669787 |
zzb111 |
D |
Oct. 24, 2017, 5:34 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
93 |
2252800 |
|
2100 |
|
31381740 |
Jayzhang |
D |
Oct. 16, 2017, 4:45 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
108 |
2150400 |
|
2100 |
|
31630619 |
permui |
D |
Oct. 23, 2017, 1:34 p.m. |
OK |
GNU C++11 |
TESTS |
46 |
108 |
2150400 |
|
2100 |
|
31363065 |
ywwyww |
D |
Oct. 15, 2017, 11:47 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
109 |
1945600 |
|
2100 |
|
31418560 |
PlayfulPanda |
D |
Oct. 16, 2017, 4:32 p.m. |
OK |
GNU C++11 |
TESTS |
46 |
109 |
2150400 |
|
2100 |
|
31360969 |
HellKitsune |
D |
Oct. 15, 2017, 10:37 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
109 |
2150400 |
|
2100 |
|
34172248 |
farmerboy |
D |
Jan. 14, 2018, 10:30 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
109 |
2150400 |
|
2100 |
|
31439590 |
xiqi |
D |
Oct. 17, 2017, 5:51 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
62 |
2048000 |
|
2100 |
|
31439507 |
xiqi |
D |
Oct. 17, 2017, 5:47 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
77 |
2048000 |
|
2100 |
|
32369340 |
Zxyelf |
D |
Nov. 17, 2017, 4:28 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
77 |
67584000 |
|
2100 |
|
31442616 |
xiqi |
D |
Oct. 17, 2017, 8:50 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
78 |
2048000 |
|
2100 |
|
31375836 |
Darts501 |
D |
Oct. 15, 2017, 7:06 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
78 |
2252800 |
|
2100 |
|
31365673 |
moguta |
D |
Oct. 15, 2017, 12:58 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
92 |
2048000 |
|
2100 |
|
32100146 |
Motarack |
D |
Nov. 6, 2017, 3:57 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
93 |
102400 |
|
2100 |
|
31621977 |
e_coder |
D |
Oct. 23, 2017, 7:39 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
93 |
2048000 |
|
2100 |
|
31417569 |
alokpatra1998 |
D |
Oct. 16, 2017, 4:02 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
93 |
2048000 |
|
2100 |
|
31361264 |
stepvah |
D |
Oct. 15, 2017, 10:52 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
93 |
2048000 |
|
2100 |
|
56543138 |
KasugaAyumu |
D |
July 5, 2019, 6:22 a.m. |
OK |
GNU C++17 |
TESTS |
46 |
124 |
102400 |
|
2100 |
|
53112977 |
UminchuR |
D |
April 22, 2019, 5:31 a.m. |
OK |
GNU C++17 |
TESTS |
46 |
139 |
102400 |
|
2100 |
|
63681547 |
vitux |
D |
Oct. 28, 2019, 8:11 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
140 |
102400 |
|
2100 |
|
59582773 |
gRaphael |
D |
Aug. 27, 2019, 4:44 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
155 |
102400 |
|
2100 |
|
57613001 |
Ztrk |
D |
July 23, 2019, 10:32 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
155 |
102400 |
|
2100 |
|
56546166 |
SheepRanger |
D |
July 5, 2019, 7:44 a.m. |
OK |
GNU C++17 |
TESTS |
46 |
171 |
102400 |
|
2100 |
|
69612686 |
ADJA |
D |
Jan. 27, 2020, 12:07 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
171 |
102400 |
|
2100 |
|
61733533 |
Bohoty |
D |
Oct. 2, 2019, 5:27 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
171 |
102400 |
|
2100 |
|
42447038 |
IgorI |
D |
Sept. 4, 2018, 4:46 a.m. |
OK |
GNU C++17 |
TESTS |
46 |
202 |
614400 |
|
2100 |
|
39596095 |
yaksha |
D |
June 24, 2018, 8:57 a.m. |
OK |
GNU C++17 |
TESTS |
46 |
217 |
204800 |
|
2100 |
|
66818230 |
potatmen |
D |
Dec. 14, 2019, 6:34 a.m. |
OK |
Java 11 |
TESTS |
46 |
842 |
0 |
|
2100 |
|
31587600 |
shankhs |
D |
Oct. 21, 2017, 9:47 p.m. |
OK |
Java 8 |
TESTS |
46 |
436 |
20684800 |
|
2100 |
|
31431239 |
kubusgol |
D |
Oct. 16, 2017, 7:17 p.m. |
OK |
Java 8 |
TESTS |
46 |
576 |
22323200 |
|
2100 |
|
31380626 |
mban259 |
D |
Oct. 16, 2017, 3:06 a.m. |
OK |
Mono C# |
TESTS |
46 |
779 |
15360000 |
|
2100 |
|
31449566 |
Miris |
D |
Oct. 17, 2017, 1:08 p.m. |
OK |
MS C++ |
TESTS |
46 |
218 |
3174400 |
|
2100 |
|
63681539 |
vitux |
D |
Oct. 28, 2019, 8:10 p.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
202 |
614400 |
|
2100 |
|
64845477 |
DarisHS |
D |
Nov. 13, 2019, 5:26 p.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
390 |
100659200 |
|
2100 |
|
64847923 |
DarisHS |
D |
Nov. 13, 2019, 6:17 p.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
405 |
100864000 |
|
2100 |
remove filters
Back to search problems