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 have an array a[1], xe2 x80 x89a[2], xe2 x80 x89..., xe2 x80 x89a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it multiple times): You do not need to minimize the number of used operations. However, you need to make sure that there are at most 5n operations. The first line contains integer n (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89105). The next line contains n distinct integers a[1], xe2 x80 x89a[2], xe2 x80 x89..., xe2 x80 x89a[n] (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89a[i] xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n). In the first line, print integer k (0 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89k xe2 x80 x89 xe2 x89 xa4 xe2 x80 x895n) -- the number of used operations. Next, print the operations. Each operation must be printed as "i j" (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89i xe2 x80 x89< xe2 x80 x89j xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n; (j xe2 x80 x89- xe2 x80 x89i xe2 x80 x89+ xe2 x80 x891) is a prime). If there are multiple answers, you can print any of them.'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
8610993 |
mrBelka |
C |
Nov. 8, 2014, 2:22 a.m. |
OK |
Delphi |
TESTS |
30 |
124 |
5017600 |
|
1800 |
7055846 |
graceoflives |
C |
July 10, 2014, 2:03 a.m. |
OK |
FPC |
TESTS |
30 |
233 |
8192000 |
|
1800 |
6731985 |
fnoi06bpby |
C |
May 29, 2014, 7:17 a.m. |
OK |
FPC |
TESTS |
30 |
405 |
5324800 |
|
1800 |
9789387 |
shencenkai |
C |
Feb. 10, 2015, 1:19 p.m. |
OK |
FPC |
TESTS |
30 |
420 |
4915200 |
|
1800 |
6660309 |
I_Love_EEvilCatt |
C |
May 20, 2014, 1:22 a.m. |
OK |
FPC |
TESTS |
30 |
436 |
5324800 |
|
1800 |
8224531 |
gyz_gyz |
C |
Oct. 14, 2014, 6:13 a.m. |
OK |
FPC |
TESTS |
30 |
436 |
6451200 |
|
1800 |
6859873 |
artem1416 |
C |
June 10, 2014, 3:40 p.m. |
OK |
FPC |
TESTS |
30 |
451 |
17305600 |
|
1800 |
6666042 |
I_love_Varechka |
C |
May 21, 2014, 8:50 a.m. |
OK |
FPC |
TESTS |
30 |
452 |
24064000 |
|
1800 |
6662854 |
WARenie |
C |
May 20, 2014, 2:35 p.m. |
OK |
FPC |
TESTS |
30 |
499 |
4403200 |
|
1800 |
9382203 |
BenderRodriguez |
C |
Jan. 7, 2015, 7:08 p.m. |
OK |
FPC |
TESTS |
30 |
514 |
14848000 |
|
1800 |
7049437 |
WARenie |
C |
July 8, 2014, 9 p.m. |
OK |
FPC |
TESTS |
30 |
529 |
4403200 |
|
1800 |
6873453 |
VvlvV |
C |
June 13, 2014, 1:46 p.m. |
OK |
GNU C |
TESTS |
30 |
109 |
5222400 |
|
1800 |
6657683 |
Kurisu |
C |
May 19, 2014, 1:17 p.m. |
OK |
GNU C |
TESTS |
30 |
109 |
5632000 |
|
1800 |
6661950 |
vis10326 |
C |
May 20, 2014, 11:13 a.m. |
OK |
GNU C |
TESTS |
30 |
109 |
5632000 |
|
1800 |
6651504 |
festivus |
C |
May 18, 2014, 3:41 p.m. |
OK |
GNU C |
TESTS |
30 |
155 |
13824000 |
|
1800 |
6653176 |
vaishious |
C |
May 18, 2014, 8:41 p.m. |
OK |
GNU C |
TESTS |
30 |
171 |
4812800 |
|
1800 |
8369374 |
vjudge3 |
C |
Oct. 23, 2014, 3:57 p.m. |
OK |
GNU C++ |
TESTS |
30 |
46 |
5427200 |
|
1800 |
9428795 |
vjudge3 |
C |
Jan. 14, 2015, 11 a.m. |
OK |
GNU C++ |
TESTS |
30 |
93 |
4710400 |
|
1800 |
8984322 |
scipianus |
C |
Dec. 4, 2014, 5:44 p.m. |
OK |
GNU C++ |
TESTS |
30 |
93 |
4710400 |
|
1800 |
6667038 |
hzwer |
C |
May 21, 2014, 12:33 p.m. |
OK |
GNU C++ |
TESTS |
30 |
93 |
4915200 |
|
1800 |
8226811 |
james007 |
C |
Oct. 14, 2014, 11:10 a.m. |
OK |
GNU C++ |
TESTS |
30 |
93 |
5632000 |
|
1800 |
6713880 |
hockey_for_NOI |
C |
May 26, 2014, 7:35 a.m. |
OK |
GNU C++ |
TESTS |
30 |
93 |
5734400 |
|
1800 |
9363525 |
namonakiaccount |
C |
Jan. 5, 2015, 3:40 a.m. |
OK |
GNU C++ |
TESTS |
30 |
108 |
4710400 |
|
1800 |
6910023 |
Stefanie |
C |
June 19, 2014, 3:55 a.m. |
OK |
GNU C++ |
TESTS |
30 |
108 |
4915200 |
|
1800 |
10410343 |
codeit22 |
C |
March 23, 2015, 12:57 p.m. |
OK |
GNU C++ |
TESTS |
30 |
108 |
5017600 |
|
1800 |
6667034 |
hzwer |
C |
May 21, 2014, 12:32 p.m. |
OK |
GNU C++ |
TESTS |
30 |
108 |
5324800 |
|
1800 |
6648810 |
alculquicondor |
C |
May 18, 2014, 5:22 a.m. |
OK |
GNU C++0x |
TESTS |
30 |
62 |
8806400 |
|
1800 |
7209831 |
hehaodele |
C |
July 23, 2014, 2:09 p.m. |
OK |
GNU C++0x |
TESTS |
30 |
93 |
5017600 |
|
1800 |
8863396 |
I_love_Hoang_Yen |
C |
Nov. 26, 2014, 6:55 p.m. |
OK |
GNU C++0x |
TESTS |
30 |
108 |
5324800 |
|
1800 |
9211796 |
saketh |
C |
Dec. 21, 2014, 12:29 a.m. |
OK |
GNU C++0x |
TESTS |
30 |
109 |
4812800 |
|
1800 |
6926434 |
sping128 |
C |
June 20, 2014, 8:55 a.m. |
OK |
GNU C++0x |
TESTS |
30 |
109 |
5017600 |
|
1800 |
6653357 |
crazypursuer |
C |
May 18, 2014, 9:57 p.m. |
OK |
GNU C++0x |
TESTS |
30 |
109 |
5017600 |
|
1800 |
7562910 |
catlak_profesor_mfb |
C |
Aug. 23, 2014, 7:51 p.m. |
OK |
GNU C++0x |
TESTS |
30 |
109 |
5222400 |
|
1800 |
7562892 |
catlak_profesor_mfb |
C |
Aug. 23, 2014, 7:49 p.m. |
OK |
GNU C++0x |
TESTS |
30 |
109 |
5222400 |
|
1800 |
6704333 |
wangxi |
C |
May 24, 2014, 1:31 p.m. |
OK |
GNU C++0x |
TESTS |
30 |
109 |
5324800 |
|
1800 |
7061051 |
betaveros |
C |
July 11, 2014, 1:13 a.m. |
OK |
GNU C++0x |
TESTS |
30 |
124 |
4710400 |
|
1800 |
57959290 |
rainboy |
C |
July 29, 2019, 8:47 p.m. |
OK |
GNU C11 |
TESTS |
30 |
842 |
3481600 |
|
1800 |
31723778 |
platypus179 |
C |
Oct. 25, 2017, 9:13 p.m. |
OK |
GNU C++11 |
TESTS |
30 |
78 |
9216000 |
|
1800 |
18696900 |
genz10 |
C |
June 24, 2016, 8:26 a.m. |
OK |
GNU C++11 |
TESTS |
30 |
109 |
4300800 |
|
1800 |
18740613 |
cchao |
C |
June 26, 2016, 5:18 p.m. |
OK |
GNU C++11 |
TESTS |
30 |
109 |
4608000 |
|
1800 |
20404804 |
KhaledMuhammad |
C |
Sept. 5, 2016, 5:24 p.m. |
OK |
GNU C++11 |
TESTS |
30 |
109 |
4608000 |
|
1800 |
11362405 |
Ra1nWarden |
C |
May 31, 2015, 3:05 a.m. |
OK |
GNU C++11 |
TESTS |
30 |
109 |
4812800 |
|
1800 |
11020287 |
Dull |
C |
May 7, 2015, 11:50 a.m. |
OK |
GNU C++11 |
TESTS |
30 |
109 |
5017600 |
|
1800 |
15762258 |
joisino |
C |
Feb. 3, 2016, 4:56 a.m. |
OK |
GNU C++11 |
TESTS |
30 |
109 |
5017600 |
|
1800 |
13867948 |
vjudge2 |
C |
Oct. 26, 2015, 7:46 a.m. |
OK |
GNU C++11 |
TESTS |
30 |
109 |
5427200 |
|
1800 |
58935371 |
vjudge1 |
C |
Aug. 17, 2019, 3:46 a.m. |
OK |
GNU C++11 |
TESTS |
30 |
109 |
5734400 |
|
1800 |
10854999 |
a1s3a |
C |
April 25, 2015, 3:28 a.m. |
OK |
GNU C++11 |
TESTS |
30 |
109 |
7065600 |
|
1800 |
27846171 |
frankbozar |
C |
June 17, 2017, 12:53 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
108 |
2048000 |
|
1800 |
55055096 |
div24ever |
C |
June 3, 2019, 6:39 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
108 |
4505600 |
|
1800 |
34167473 |
Jeffrey |
C |
Jan. 14, 2018, 5:46 a.m. |
OK |
GNU C++14 |
TESTS |
30 |
108 |
5836800 |
|
1800 |
30744093 |
spj_29 |
C |
Sept. 26, 2017, 8:15 a.m. |
OK |
GNU C++14 |
TESTS |
30 |
108 |
11878400 |
|
1800 |
27846186 |
frankbozar |
C |
June 17, 2017, 12:54 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
109 |
1638400 |
|
1800 |
48213076 |
dan04 |
C |
Jan. 11, 2019, 1:10 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
109 |
4403200 |
|
1800 |
27846088 |
frankbozar |
C |
June 17, 2017, 12:48 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
109 |
4505600 |
|
1800 |
39002461 |
xvk9 |
C |
June 6, 2018, 7:04 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
109 |
4505600 |
|
1800 |
38419745 |
vjudge3 |
C |
May 19, 2018, 6:36 a.m. |
OK |
GNU C++14 |
TESTS |
30 |
109 |
4505600 |
|
1800 |
32379032 |
dionysios |
C |
Nov. 17, 2017, 1:04 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
109 |
4505600 |
|
1800 |
55804201 |
yuhta |
C |
June 19, 2019, 8:50 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
109 |
4505600 |
|
1800 |
66288392 |
tihoson |
C |
Dec. 4, 2019, 8:30 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
109 |
5120000 |
|
1800 |
67860799 |
Claustrophobic_Penguin |
C |
Dec. 29, 2019, 8:05 a.m. |
OK |
GNU C++17 |
TESTS |
30 |
124 |
4403200 |
|
1800 |
41964229 |
Photon_ |
C |
Aug. 22, 2018, 11:23 a.m. |
OK |
GNU C++17 |
TESTS |
30 |
124 |
4608000 |
|
1800 |
41255513 |
3agwa |
C |
Aug. 5, 2018, 7:45 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
124 |
4710400 |
|
1800 |
41255506 |
3agwa |
C |
Aug. 5, 2018, 7:45 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
124 |
4710400 |
|
1800 |
50340098 |
TomazGomes |
C |
Feb. 23, 2019, 1:15 a.m. |
OK |
GNU C++17 |
TESTS |
30 |
124 |
4710400 |
|
1800 |
61355844 |
samurai123 |
C |
Sept. 27, 2019, 10:23 a.m. |
OK |
GNU C++17 |
TESTS |
30 |
124 |
4710400 |
|
1800 |
58431829 |
ruo |
C |
Aug. 7, 2019, 12:12 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
124 |
4710400 |
|
1800 |
51748613 |
themechanicalcoder |
C |
March 23, 2019, 8:38 a.m. |
OK |
GNU C++17 |
TESTS |
30 |
124 |
4710400 |
|
1800 |
6664818 |
erikr |
C |
May 21, 2014, 2:11 a.m. |
OK |
Haskell |
TESTS |
30 |
187 |
12800000 |
|
1800 |
9347482 |
xiaowuc1 |
C |
Jan. 2, 2015, 4:29 p.m. |
OK |
Java 6 |
TESTS |
30 |
187 |
0 |
|
1800 |
7290519 |
khoahoc1024 |
C |
July 30, 2014, 7:35 a.m. |
OK |
Java 6 |
TESTS |
30 |
639 |
16486400 |
|
1800 |
7544406 |
maitony |
C |
Aug. 21, 2014, 2:06 p.m. |
OK |
Java 6 |
TESTS |
30 |
1700 |
13209600 |
|
1800 |
7279255 |
TranCongDuy |
C |
July 28, 2014, 3:36 p.m. |
OK |
Java 7 |
TESTS |
30 |
170 |
15052800 |
|
1800 |
14872495 |
DukeOfYork |
C |
Dec. 19, 2015, 8:51 a.m. |
OK |
Java 7 |
TESTS |
30 |
202 |
0 |
|
1800 |
8550395 |
megaspazz |
C |
Nov. 4, 2014, 6:07 p.m. |
OK |
Java 7 |
TESTS |
30 |
217 |
14233600 |
|
1800 |
6865921 |
VirrageS |
C |
June 11, 2014, 8:06 p.m. |
OK |
Java 7 |
TESTS |
30 |
218 |
102400 |
|
1800 |
7443725 |
edorundo |
C |
Aug. 13, 2014, 3:26 p.m. |
OK |
Java 7 |
TESTS |
30 |
264 |
2457600 |
|
1800 |
10651530 |
Sumeet.Varma |
C |
April 10, 2015, 6:07 p.m. |
OK |
Java 7 |
TESTS |
30 |
265 |
8499200 |
|
1800 |
8054755 |
monsterspy |
C |
Oct. 2, 2014, 8:24 a.m. |
OK |
Java 7 |
TESTS |
30 |
280 |
8396800 |
|
1800 |
6682599 |
skull |
C |
May 22, 2014, 4:23 p.m. |
OK |
Java 7 |
TESTS |
30 |
374 |
204800 |
|
1800 |
9533729 |
Amijan920 |
C |
Jan. 24, 2015, 4:10 a.m. |
OK |
Java 7 |
TESTS |
30 |
420 |
16896000 |
|
1800 |
9534482 |
miguel_palma |
C |
Jan. 24, 2015, 6:04 a.m. |
OK |
Java 7 |
TESTS |
30 |
420 |
19763200 |
|
1800 |
27448031 |
kunal_khatri |
C |
May 30, 2017, 12:24 p.m. |
OK |
Java 8 |
TESTS |
30 |
187 |
15257600 |
|
1800 |
31433867 |
VerticesEdge |
C |
Oct. 16, 2017, 10:04 p.m. |
OK |
Java 8 |
TESTS |
30 |
202 |
37478400 |
|
1800 |
9941210 |
niyaznigmatul |
C |
Feb. 20, 2015, 6:48 p.m. |
OK |
Java 8 |
TESTS |
30 |
218 |
0 |
|
1800 |
11517089 |
chqianu |
C |
June 10, 2015, 5:13 a.m. |
OK |
Java 8 |
TESTS |
30 |
218 |
0 |
|
1800 |
12117610 |
redbell014 |
C |
July 19, 2015, 2:25 p.m. |
OK |
Java 8 |
TESTS |
30 |
233 |
16179200 |
|
1800 |
61314642 |
adeepgarg13 |
C |
Sept. 26, 2019, 10:37 a.m. |
OK |
Java 8 |
TESTS |
30 |
234 |
13926400 |
|
1800 |
12794150 |
Abkreno94 |
C |
Aug. 31, 2015, 8:06 p.m. |
OK |
Java 8 |
TESTS |
30 |
234 |
14336000 |
|
1800 |
59565250 |
kocko |
C |
Aug. 27, 2019, 10:28 a.m. |
OK |
Java 8 |
TESTS |
30 |
249 |
6860800 |
|
1800 |
9593679 |
mtf |
C |
Jan. 27, 2015, 8:27 p.m. |
OK |
Java 8 |
TESTS |
30 |
249 |
13414400 |
|
1800 |
68709086 |
adarsh000321 |
C |
Jan. 13, 2020, 12:22 p.m. |
OK |
Java 8 |
TESTS |
30 |
249 |
14950400 |
|
1800 |
6685706 |
Eeyore |
C |
May 23, 2014, 7:39 a.m. |
OK |
JavaScript |
TESTS |
30 |
280 |
52940800 |
|
1800 |
8825315 |
mrBelka |
C |
Nov. 23, 2014, 2:49 p.m. |
OK |
Mono C# |
TESTS |
30 |
794 |
21708800 |
|
1800 |
10034054 |
camypaper |
C |
Feb. 26, 2015, 3:12 p.m. |
OK |
MS C# |
TESTS |
30 |
202 |
12595200 |
|
1800 |
6648918 |
azukun |
C |
May 18, 2014, 5:57 a.m. |
OK |
MS C# |
TESTS |
30 |
234 |
30617600 |
|
1800 |
58410545 |
vjudge2 |
C |
Aug. 7, 2019, 1:21 a.m. |
OK |
MS C++ |
TESTS |
30 |
93 |
4915200 |
|
1800 |
13835501 |
vjudge1 |
C |
Oct. 25, 2015, 8:21 a.m. |
OK |
MS C++ |
TESTS |
30 |
109 |
4915200 |
|
1800 |
6651988 |
Rivx |
C |
May 18, 2014, 5:26 p.m. |
OK |
MS C++ |
TESTS |
30 |
109 |
5529600 |
|
1800 |
9481683 |
hakobyan.tigran |
C |
Jan. 20, 2015, 5:35 a.m. |
OK |
MS C++ |
TESTS |
30 |
109 |
5632000 |
|
1800 |
6650942 |
Vlad_kv |
C |
May 18, 2014, 1:46 p.m. |
OK |
MS C++ |
TESTS |
30 |
124 |
4812800 |
|
1800 |
13835571 |
vjudge4 |
C |
Oct. 25, 2015, 8:26 a.m. |
OK |
MS C++ |
TESTS |
30 |
124 |
4915200 |
|
1800 |
6708845 |
ssj1996 |
C |
May 25, 2014, 8:48 a.m. |
OK |
MS C++ |
TESTS |
30 |
124 |
5120000 |
|
1800 |
13835389 |
vjudge4 |
C |
Oct. 25, 2015, 8:13 a.m. |
OK |
MS C++ |
TESTS |
30 |
124 |
5222400 |
|
1800 |
6663779 |
tcet030840zxp |
C |
May 20, 2014, 6:16 p.m. |
OK |
MS C++ |
TESTS |
30 |
124 |
5222400 |
|
1800 |
18908504 |
prateep |
C |
July 5, 2016, 11:25 p.m. |
OK |
MS C++ |
TESTS |
30 |
124 |
5632000 |
|
1800 |
11347959 |
dr.ikros |
C |
May 29, 2015, 3:54 p.m. |
OK |
PyPy 3 |
TESTS |
30 |
1044 |
36761600 |
|
1800 |
6654090 |
changyuheng |
C |
May 19, 2014, 3:55 a.m. |
OK |
Python 3 |
TESTS |
30 |
810 |
27648000 |
|
1800 |
42135545 |
Mk_Python_v1 |
C |
Aug. 26, 2018, 11:20 p.m. |
OK |
Python 3 |
TESTS |
30 |
904 |
27545600 |
|
1800 |
6683510 |
yugle7 |
C |
May 22, 2014, 8:08 p.m. |
OK |
Python 3 |
TESTS |
30 |
1091 |
29184000 |
|
1800 |
41908384 |
JTD_V |
C |
Aug. 20, 2018, 3:57 p.m. |
OK |
Python 3 |
TESTS |
30 |
1403 |
28160000 |
|
1800 |
6649627 |
hama-du |
C |
May 18, 2014, 8:48 a.m. |
OK |
Scala |
TESTS |
30 |
654 |
3891200 |
|
1800 |
remove filters
Back to search problems