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
B'You are given a permutation p of integers from 0 to n-1 (each of them occurs exactly once). Initially, the permutation is not sorted (that is, p_i>p_{i+1} for at least one 1 <= i <= n - 1 ). The permutation is called X -sortable for some non-negative integer X if it is possible to sort the permutation by performing the operation below some finite number of times: Here & denotes the bitwise AND operation. Find the maximum value of X such that p is X -sortable. It can be shown that there always exists some value of X such that p is X -sortable. The input consists of multiple test cases. The first line contains a single integer t (1 <= t <= 10^4) -- the number of test cases. Description of test cases follows. The first line of each test case contains a single integer n (2 <= n <= 2 cdot 10^5) -- the length of the permutation. The second line of each test case contains n integers p_1, p_2, ..., p_n ( 0 <= p_i <= n-1 , all p_i are distinct) -- the elements of p . It is guaranteed that p is not sorted. It is guaranteed that the sum of n over all cases does not exceed 2 cdot 10^5 . For each test case output a single integer -- the maximum value of X such that p is X -sortable. In the first test case, the only X for which the permutation is X -sortable are X = 0 and X = 2 , maximum of which is 2 . Sorting using X = 0 : Sorting using X = 2 : In the second test case, we must swap p_1 and p_2 which is possible only with X = 0 . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
158112374 |
FortyFour |
B |
May 23, 2022, 5:04 a.m. |
OK |
C# 10 |
TESTS |
15 |
155 |
13619200 |
|
|
158248831 |
majer442 |
B |
May 23, 2022, 10:22 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
15 |
764 |
0 |
|
|
158250373 |
majer442 |
B |
May 23, 2022, 11:23 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
15 |
826 |
0 |
|
|
158248998 |
majer442 |
B |
May 23, 2022, 10:28 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
15 |
826 |
0 |
|
|
158122871 |
ashu2002anand |
B |
May 23, 2022, 7:41 a.m. |
OK |
GNU C11 |
TESTS |
15 |
61 |
819200 |
|
|
158147756 |
Ashraful_Goni |
B |
May 23, 2022, 1:23 p.m. |
OK |
GNU C11 |
TESTS |
15 |
62 |
0 |
|
|
158149655 |
loki_7 |
B |
May 23, 2022, 1:48 p.m. |
OK |
GNU C11 |
TESTS |
15 |
62 |
0 |
|
|
158139049 |
1435730 |
B |
May 23, 2022, 11:37 a.m. |
OK |
GNU C11 |
TESTS |
15 |
62 |
0 |
|
|
158112535 |
chnaveen |
B |
May 23, 2022, 5:07 a.m. |
OK |
GNU C11 |
TESTS |
15 |
78 |
1536000 |
|
|
158254162 |
ZhangCW_QwQ |
B |
May 24, 2022, 1:39 a.m. |
OK |
GNU C++14 |
TESTS |
15 |
15 |
2867200 |
|
|
158117591 |
zltzlt |
B |
May 23, 2022, 6:24 a.m. |
OK |
GNU C++14 |
TESTS |
15 |
46 |
0 |
|
|
158107800 |
albertbow |
B |
May 23, 2022, 3:39 a.m. |
OK |
GNU C++14 |
TESTS |
15 |
46 |
0 |
|
|
158133654 |
le0n |
B |
May 23, 2022, 10:23 a.m. |
OK |
GNU C++14 |
TESTS |
15 |
46 |
0 |
|
|
158123489 |
OvO_Zuo |
B |
May 23, 2022, 7:51 a.m. |
OK |
GNU C++14 |
TESTS |
15 |
46 |
0 |
|
|
158151939 |
wxhtzw--hh |
B |
May 23, 2022, 2:16 p.m. |
OK |
GNU C++14 |
TESTS |
15 |
46 |
0 |
|
|
158231103 |
j30 |
B |
May 23, 2022, 5:21 p.m. |
OK |
GNU C++14 |
TESTS |
15 |
46 |
0 |
|
|
158137316 |
defender1234 |
B |
May 23, 2022, 11:16 a.m. |
OK |
GNU C++14 |
TESTS |
15 |
46 |
0 |
|
|
158535603 |
vjudge3 |
B |
May 26, 2022, 2:06 p.m. |
OK |
GNU C++14 |
TESTS |
15 |
46 |
819200 |
|
|
158346372 |
Psaily |
B |
May 25, 2022, 3:16 a.m. |
OK |
GNU C++14 |
TESTS |
15 |
46 |
819200 |
|
|
158251974 |
zhangmj2008 |
B |
May 24, 2022, 12:32 a.m. |
OK |
GNU C++17 |
TESTS |
15 |
46 |
0 |
|
|
158248887 |
Muhammad98 |
B |
May 23, 2022, 10:24 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
46 |
0 |
|
|
158206117 |
AnasAbbas |
B |
May 23, 2022, 3:51 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
46 |
0 |
|
|
158145652 |
kuaileshiwo |
B |
May 23, 2022, 12:58 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
46 |
0 |
|
|
158144034 |
chinaxszyx |
B |
May 23, 2022, 12:39 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
46 |
0 |
|
|
158360744 |
WULI |
B |
May 25, 2022, 7:28 a.m. |
OK |
GNU C++17 |
TESTS |
15 |
46 |
0 |
|
|
158306604 |
aditya_AR7 |
B |
May 24, 2022, 2:16 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
46 |
0 |
|
|
158360725 |
WULI |
B |
May 25, 2022, 7:28 a.m. |
OK |
GNU C++17 |
TESTS |
15 |
46 |
0 |
|
|
158581900 |
TsReaper |
B |
May 27, 2022, 5:27 a.m. |
OK |
GNU C++17 |
TESTS |
15 |
46 |
0 |
|
|
158412927 |
Motiky007 |
B |
May 25, 2022, 5:24 p.m. |
OK |
GNU C++17 |
TESTS |
15 |
46 |
0 |
|
|
158360986 |
xiece666 |
B |
May 25, 2022, 7:31 a.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
15 |
1843200 |
|
|
158153084 |
walid90 |
B |
May 23, 2022, 2:30 p.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
31 |
0 |
|
|
158231018 |
siliconoxide4 |
B |
May 23, 2022, 5:20 p.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
31 |
0 |
|
|
158110121 |
vladislav228 |
B |
May 23, 2022, 4:27 a.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
31 |
0 |
|
|
158163483 |
virt_contest_taker |
B |
May 23, 2022, 2:46 p.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
31 |
819200 |
|
|
158241160 |
kwee |
B |
May 23, 2022, 7:30 p.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
31 |
819200 |
|
|
158271181 |
exzang |
B |
May 24, 2022, 6:48 a.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
31 |
819200 |
|
|
158389980 |
Nanako |
B |
May 25, 2022, 12:54 p.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
31 |
819200 |
|
|
158105888 |
PCC |
B |
May 23, 2022, 2:58 a.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
31 |
819200 |
|
|
158135948 |
_Yeager_ |
B |
May 23, 2022, 10:57 a.m. |
OK |
GNU C++17 (64) |
TESTS |
15 |
31 |
819200 |
|
|
158140863 |
Bungmint |
B |
May 23, 2022, 11:59 a.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
15 |
819200 |
|
|
158147189 |
luogu_bot2 |
B |
May 23, 2022, 1:16 p.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
15 |
2969600 |
|
|
158125214 |
vinayak_7989 |
B |
May 23, 2022, 8:19 a.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
15 |
24064000 |
|
|
158269221 |
vansh_madbomb |
B |
May 24, 2022, 6:16 a.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
30 |
0 |
|
|
158112684 |
YoussefMagdy |
B |
May 23, 2022, 5:09 a.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
30 |
819200 |
|
|
158305153 |
Followall |
B |
May 24, 2022, 1:59 p.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
30 |
32051200 |
|
|
158493347 |
lucky_333 |
B |
May 26, 2022, 5:42 a.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
31 |
0 |
|
|
158557615 |
mayankmp1224 |
B |
May 26, 2022, 6:19 p.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
31 |
0 |
|
|
158546077 |
p.ferrari |
B |
May 26, 2022, 3:54 p.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
31 |
0 |
|
|
158484908 |
Venti_chai |
B |
May 26, 2022, 3:11 a.m. |
OK |
GNU C++20 (64) |
TESTS |
15 |
31 |
0 |
|
|
158313421 |
prituladima |
B |
May 24, 2022, 3:31 p.m. |
OK |
Java 11 |
TESTS |
15 |
171 |
0 |
|
|
158139845 |
poopoop |
B |
May 23, 2022, 11:47 a.m. |
OK |
Java 11 |
TESTS |
15 |
171 |
0 |
|
|
158119353 |
_Astron |
B |
May 23, 2022, 6:50 a.m. |
OK |
Java 11 |
TESTS |
15 |
187 |
0 |
|
|
158122917 |
Hreshi |
B |
May 23, 2022, 7:42 a.m. |
OK |
Java 11 |
TESTS |
15 |
202 |
0 |
|
|
158580684 |
Rohitttt |
B |
May 27, 2022, 5:04 a.m. |
OK |
Java 11 |
TESTS |
15 |
202 |
0 |
|
|
158380853 |
freehandle |
B |
May 25, 2022, 11:02 a.m. |
OK |
Java 11 |
TESTS |
15 |
202 |
0 |
|
|
158314980 |
suhas5979 |
B |
May 24, 2022, 3:48 p.m. |
OK |
Java 11 |
TESTS |
15 |
202 |
0 |
|
|
158109262 |
aditya2024 |
B |
May 23, 2022, 4:09 a.m. |
OK |
Java 11 |
TESTS |
15 |
202 |
0 |
|
|
158108770 |
rachitagrawal1011 |
B |
May 23, 2022, 4 a.m. |
OK |
Java 11 |
TESTS |
15 |
202 |
0 |
|
|
158293776 |
gaurav_g |
B |
May 24, 2022, 11:49 a.m. |
OK |
Java 11 |
TESTS |
15 |
217 |
0 |
|
|
158109374 |
sharma_ji_420 |
B |
May 23, 2022, 4:12 a.m. |
OK |
Java 8 |
TESTS |
15 |
93 |
0 |
|
|
158107759 |
priority_is_greedy |
B |
May 23, 2022, 3:38 a.m. |
OK |
Java 8 |
TESTS |
15 |
93 |
0 |
|
|
158116409 |
Main.Thread |
B |
May 23, 2022, 6:07 a.m. |
OK |
Java 8 |
TESTS |
15 |
108 |
0 |
|
|
158539797 |
DEMO23 |
B |
May 26, 2022, 2:46 p.m. |
OK |
Java 8 |
TESTS |
15 |
109 |
0 |
|
|
158152324 |
gssakash |
B |
May 23, 2022, 2:20 p.m. |
OK |
Java 8 |
TESTS |
15 |
109 |
1843200 |
|
|
158336807 |
dev_14 |
B |
May 24, 2022, 9:11 p.m. |
OK |
Java 8 |
TESTS |
15 |
124 |
1843200 |
|
|
158126695 |
kewosihuzuobudao |
B |
May 23, 2022, 8:40 a.m. |
OK |
Java 8 |
TESTS |
15 |
124 |
2764800 |
|
|
158357761 |
abdoad941 |
B |
May 25, 2022, 6:46 a.m. |
OK |
Java 8 |
TESTS |
15 |
139 |
1945600 |
|
|
158541353 |
C_P_T_N |
B |
May 26, 2022, 3 p.m. |
OK |
Java 8 |
TESTS |
15 |
140 |
1843200 |
|
|
158352411 |
Swapniltri |
B |
May 25, 2022, 5:29 a.m. |
OK |
Java 8 |
TESTS |
15 |
140 |
2764800 |
|
|
158121443 |
ripity |
B |
May 23, 2022, 7:21 a.m. |
OK |
Kotlin 1.6 |
TESTS |
15 |
217 |
0 |
|
|
158269602 |
housni |
B |
May 24, 2022, 6:21 a.m. |
OK |
Kotlin 1.6 |
TESTS |
15 |
311 |
14950400 |
|
|
158270429 |
housni |
B |
May 24, 2022, 6:33 a.m. |
OK |
Kotlin 1.6 |
TESTS |
15 |
327 |
14950400 |
|
|
158105444 |
buhuidaima |
B |
May 23, 2022, 2:48 a.m. |
OK |
MS C++ 2017 |
TESTS |
15 |
140 |
0 |
|
|
158267005 |
gao_wu_di |
B |
May 24, 2022, 5:43 a.m. |
OK |
MS C++ 2017 |
TESTS |
15 |
140 |
819200 |
|
|
158248042 |
Bu1izhnik |
B |
May 23, 2022, 9:57 p.m. |
OK |
MS C++ 2017 |
TESTS |
15 |
156 |
819200 |
|
|
158290746 |
xsc |
B |
May 24, 2022, 11:13 a.m. |
OK |
MS C++ 2017 |
TESTS |
15 |
156 |
1638400 |
|
|
158388595 |
Main_Slayer |
B |
May 25, 2022, 12:38 p.m. |
OK |
MS C++ 2017 |
TESTS |
15 |
156 |
1740800 |
|
|
158407916 |
Serg108N |
B |
May 25, 2022, 4:21 p.m. |
OK |
MS C++ 2017 |
TESTS |
15 |
171 |
819200 |
|
|
158117561 |
adesh123 |
B |
May 23, 2022, 6:24 a.m. |
OK |
MS C++ 2017 |
TESTS |
15 |
171 |
1740800 |
|
|
158104708 |
lemiao12 |
B |
May 23, 2022, 2:30 a.m. |
OK |
PyPy 3 |
TESTS |
15 |
109 |
15360000 |
|
|
158306812 |
YMSeah |
B |
May 24, 2022, 2:19 p.m. |
OK |
PyPy 3 |
TESTS |
15 |
109 |
18329600 |
|
|
158239715 |
hxu10 |
B |
May 23, 2022, 7:08 p.m. |
OK |
PyPy 3 |
TESTS |
15 |
124 |
15360000 |
|
|
158306559 |
ambs_ |
B |
May 24, 2022, 2:16 p.m. |
OK |
PyPy 3 |
TESTS |
15 |
187 |
16384000 |
|
|
158115380 |
ON_THE_EDGE |
B |
May 23, 2022, 5:52 a.m. |
OK |
PyPy 3 |
TESTS |
15 |
202 |
16896000 |
|
|
158141282 |
ArjitShrivastava |
B |
May 23, 2022, 12:05 p.m. |
OK |
PyPy 3 |
TESTS |
15 |
202 |
16998400 |
|
|
158577230 |
jscn |
B |
May 27, 2022, 3:35 a.m. |
OK |
PyPy 3 |
TESTS |
15 |
218 |
18329600 |
|
|
158332900 |
Deltasirius |
B |
May 24, 2022, 7:39 p.m. |
OK |
PyPy 3 |
TESTS |
15 |
218 |
18329600 |
|
|
158119539 |
practise_iiitb |
B |
May 23, 2022, 6:53 a.m. |
OK |
PyPy 3 |
TESTS |
15 |
233 |
14848000 |
|
|
158105511 |
mmooyyii |
B |
May 23, 2022, 2:50 a.m. |
OK |
PyPy 3 |
TESTS |
15 |
326 |
19251200 |
|
|
158146310 |
only_for_kav_tripathi |
B |
May 23, 2022, 1:06 p.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
108 |
19558400 |
|
|
158565679 |
nealzane |
B |
May 26, 2022, 8:46 p.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
109 |
16281600 |
|
|
158133897 |
skp_r |
B |
May 23, 2022, 10:26 a.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
124 |
27955200 |
|
|
158134405 |
tushar26427 |
B |
May 23, 2022, 10:34 a.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
139 |
27443200 |
|
|
158119874 |
tassei903 |
B |
May 23, 2022, 6:57 a.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
171 |
21504000 |
|
|
158146455 |
DarkHorse_it_iz |
B |
May 23, 2022, 1:07 p.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
171 |
26214400 |
|
|
158114364 |
sharingan000 |
B |
May 23, 2022, 5:36 a.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
186 |
17612800 |
|
|
158265624 |
abineth |
B |
May 24, 2022, 5:21 a.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
186 |
25190400 |
|
|
158390247 |
satyamshrma |
B |
May 25, 2022, 12:57 p.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
202 |
23244800 |
|
|
158130242 |
ktthree |
B |
May 23, 2022, 9:31 a.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
202 |
25190400 |
|
|
158348654 |
pennymagic156 |
B |
May 25, 2022, 4:18 a.m. |
OK |
Python 3 |
TESTS |
15 |
124 |
14233600 |
|
|
158252986 |
CodeLike |
B |
May 24, 2022, 1:06 a.m. |
OK |
Python 3 |
TESTS |
15 |
139 |
14233600 |
|
|
158494603 |
Eldababa |
B |
May 26, 2022, 5:59 a.m. |
OK |
Python 3 |
TESTS |
15 |
155 |
14233600 |
|
|
158279078 |
sarius129 |
B |
May 24, 2022, 8:37 a.m. |
OK |
Python 3 |
TESTS |
15 |
155 |
15155200 |
|
|
158556821 |
MishaTsekh |
B |
May 26, 2022, 6:09 p.m. |
OK |
Python 3 |
TESTS |
15 |
156 |
10854400 |
|
|
158399990 |
Harsha3408 |
B |
May 25, 2022, 2:55 p.m. |
OK |
Python 3 |
TESTS |
15 |
156 |
10854400 |
|
|
158343545 |
siddartha321 |
B |
May 25, 2022, 1:54 a.m. |
OK |
Python 3 |
TESTS |
15 |
171 |
14233600 |
|
|
158153348 |
abhipandey9315 |
B |
May 23, 2022, 2:33 p.m. |
OK |
Python 3 |
TESTS |
15 |
171 |
14233600 |
|
|
158130906 |
ImVikash |
B |
May 23, 2022, 9:41 a.m. |
OK |
Python 3 |
TESTS |
15 |
171 |
14233600 |
|
|
158130442 |
ImVikash |
B |
May 23, 2022, 9:34 a.m. |
OK |
Python 3 |
TESTS |
15 |
171 |
14233600 |
|
|
158112748 |
Spheniscine |
B |
May 23, 2022, 5:10 a.m. |
OK |
Rust 2021 |
TESTS |
15 |
31 |
102400 |
|
|
remove filters
Back to search problems