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"Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya got an array consisting of n numbers, it is the gift for his birthday. Now he wants to sort it in the non-decreasing order. However, a usual sorting is boring to perform, that's why Petya invented the following limitation: one can swap any two numbers but only if at least one of them is lucky. Your task is to sort the array according to the specified limitation. Find any possible sequence of the swaps (the number of operations in the sequence should not exceed 2n). The first line contains an integer n (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89105) -- the number of elements in the array. The second line contains n positive integers, not exceeding 109 -- the array that needs to be sorted in the non-decreasing order. On the first line print number k (0 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89k xe2 x80 x89 xe2 x89 xa4 xe2 x80 x892n) -- the number of the swaps in the sorting. On the following k lines print one pair of distinct numbers (a pair per line) -- the indexes of elements to swap. The numbers in the array are numbered starting from 1. If it is impossible to sort the given sequence, print the single number -1. If there are several solutions, output any. Note that you don't have to minimize k. Any sorting with no more than 2n swaps is accepted."... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
649277 |
evg-zhabotinsky |
D |
Aug. 29, 2011, 5:58 p.m. |
OK |
Delphi |
TESTS |
76 |
90 |
3788800 |
|
2000 |
644534 |
tourist |
D |
Aug. 29, 2011, 4:22 p.m. |
OK |
Delphi |
TESTS |
76 |
110 |
9728000 |
|
2000 |
40992383 |
ReaLNero1 |
D |
July 31, 2018, 1:17 a.m. |
OK |
Delphi |
TESTS |
76 |
154 |
2867200 |
|
2000 |
649551 |
Nikolai |
D |
Aug. 29, 2011, 6:54 p.m. |
OK |
Delphi |
TESTS |
76 |
200 |
30003200 |
|
2000 |
740401 |
superpear |
D |
Oct. 7, 2011, 10 a.m. |
OK |
FPC |
TESTS |
76 |
90 |
8192000 |
|
2000 |
791531 |
LifeKeeper |
D |
Oct. 23, 2011, 8:28 a.m. |
OK |
FPC |
TESTS |
76 |
110 |
5017600 |
|
2000 |
649860 |
azaky |
D |
Aug. 29, 2011, 7:14 p.m. |
OK |
FPC |
TESTS |
76 |
110 |
8192000 |
|
2000 |
649747 |
vlad107 |
D |
Aug. 29, 2011, 7:04 p.m. |
OK |
FPC |
TESTS |
76 |
110 |
18022400 |
|
2000 |
669152 |
vjudge2 |
D |
Sept. 5, 2011, 11:58 a.m. |
OK |
FPC |
TESTS |
76 |
130 |
4198400 |
|
2000 |
649138 |
xujie |
D |
Aug. 29, 2011, 5:55 p.m. |
OK |
FPC |
TESTS |
76 |
130 |
5222400 |
|
2000 |
654599 |
cherudim |
D |
Sept. 1, 2011, 11:27 a.m. |
OK |
FPC |
TESTS |
76 |
130 |
5427200 |
|
2000 |
655958 |
giongto35 |
D |
Sept. 2, 2011, 1:54 p.m. |
OK |
FPC |
TESTS |
76 |
130 |
9830400 |
|
2000 |
1243646 |
zanoes |
D |
Feb. 29, 2012, 1:59 p.m. |
OK |
FPC |
TESTS |
76 |
130 |
10649600 |
|
2000 |
671911 |
coolinging |
D |
Sept. 7, 2011, 9:32 a.m. |
OK |
FPC |
TESTS |
76 |
140 |
3788800 |
|
2000 |
646577 |
scottai1 |
D |
Aug. 29, 2011, 4:56 p.m. |
OK |
GNU C |
TESTS |
76 |
160 |
5017600 |
|
2000 |
648824 |
eduardische |
D |
Aug. 29, 2011, 5:49 p.m. |
OK |
GNU C |
TESTS |
76 |
190 |
4608000 |
|
2000 |
647977 |
-.- |
D |
Aug. 29, 2011, 5:28 p.m. |
OK |
GNU C |
TESTS |
76 |
630 |
4608000 |
|
2000 |
833010 |
kawatea |
D |
Nov. 3, 2011, 9:26 p.m. |
OK |
GNU C |
TESTS |
76 |
640 |
5017600 |
|
2000 |
2222918 |
trunghieu11 |
D |
Sept. 20, 2012, 11:04 a.m. |
OK |
GNU C++ |
TESTS |
76 |
78 |
6758400 |
|
2000 |
3911694 |
stevenkplus |
D |
June 17, 2013, 10:47 p.m. |
OK |
GNU C++ |
TESTS |
76 |
125 |
2457600 |
|
2000 |
3698507 |
ftiasch |
D |
May 10, 2013, 8:08 a.m. |
OK |
GNU C++ |
TESTS |
76 |
140 |
5017600 |
|
2000 |
2583411 |
ytau |
D |
Nov. 18, 2012, 4:22 a.m. |
OK |
GNU C++ |
TESTS |
76 |
156 |
3686400 |
|
2000 |
15141686 |
HappyNewYearMike |
D |
Dec. 31, 2015, 9:46 p.m. |
OK |
GNU C++ |
TESTS |
76 |
156 |
5222400 |
|
2000 |
2416232 |
LGM |
D |
Oct. 23, 2012, 7:35 a.m. |
OK |
GNU C++ |
TESTS |
76 |
156 |
5222400 |
|
2000 |
770936 |
st.krwlng |
D |
Oct. 17, 2011, 12:56 p.m. |
OK |
GNU C++ |
TESTS |
76 |
160 |
2252800 |
|
2000 |
648454 |
rudradevbasak |
D |
Aug. 29, 2011, 5:40 p.m. |
OK |
GNU C++ |
TESTS |
76 |
160 |
3174400 |
|
2000 |
652775 |
rudradevbasak |
D |
Aug. 30, 2011, 6:33 p.m. |
OK |
GNU C++ |
TESTS |
76 |
160 |
3174400 |
|
2000 |
650015 |
esrever |
D |
Aug. 29, 2011, 7:32 p.m. |
OK |
GNU C++ |
TESTS |
76 |
160 |
5017600 |
|
2000 |
6649587 |
FancyCoder |
D |
May 18, 2014, 8:39 a.m. |
OK |
GNU C++0x |
TESTS |
76 |
186 |
3584000 |
|
2000 |
6718391 |
marat.snowbear |
D |
May 26, 2014, 11:49 p.m. |
OK |
GNU C++0x |
TESTS |
76 |
186 |
5632000 |
|
2000 |
646695 |
watashi |
D |
Aug. 29, 2011, 4:58 p.m. |
OK |
GNU C++0x |
TESTS |
76 |
190 |
5427200 |
|
2000 |
651713 |
Archon.JK |
D |
Aug. 30, 2011, 8:25 a.m. |
OK |
GNU C++0x |
TESTS |
76 |
190 |
6246400 |
|
2000 |
647732 |
Archon.JK |
D |
Aug. 29, 2011, 5:22 p.m. |
OK |
GNU C++0x |
TESTS |
76 |
190 |
6246400 |
|
2000 |
649230 |
chyx |
D |
Aug. 29, 2011, 5:57 p.m. |
OK |
GNU C++0x |
TESTS |
76 |
200 |
6348800 |
|
2000 |
10202657 |
I_love_Hoang_Yen |
D |
March 8, 2015, 8:44 a.m. |
OK |
GNU C++0x |
TESTS |
76 |
218 |
5324800 |
|
2000 |
646592 |
MinakoKojima |
D |
Aug. 29, 2011, 4:56 p.m. |
OK |
GNU C++0x |
TESTS |
76 |
380 |
5734400 |
|
2000 |
648092 |
sexyprincess91 |
D |
Aug. 29, 2011, 5:31 p.m. |
OK |
GNU C++0x |
TESTS |
76 |
410 |
6860800 |
|
2000 |
2657154 |
cxlove |
D |
Nov. 26, 2012, 10:34 a.m. |
OK |
GNU C++0x |
TESTS |
76 |
468 |
4403200 |
|
2000 |
59233846 |
rainboy |
D |
Aug. 21, 2019, 4:36 p.m. |
OK |
GNU C11 |
TESTS |
76 |
1528 |
2457600 |
|
2000 |
32567825 |
McGinn |
D |
Nov. 23, 2017, 6:39 a.m. |
OK |
GNU C++11 |
TESTS |
76 |
156 |
4812800 |
|
2000 |
12492315 |
strawbreey |
D |
Aug. 13, 2015, 1:15 p.m. |
OK |
GNU C++11 |
TESTS |
76 |
186 |
5017600 |
|
2000 |
12524211 |
strawbreey |
D |
Aug. 14, 2015, 6:28 a.m. |
OK |
GNU C++11 |
TESTS |
76 |
186 |
5017600 |
|
2000 |
67273663 |
ElangBondol |
D |
Dec. 20, 2019, 9:21 a.m. |
OK |
GNU C++11 |
TESTS |
76 |
186 |
5529600 |
|
2000 |
27717096 |
423555290 |
D |
June 11, 2017, 7:57 a.m. |
OK |
GNU C++11 |
TESTS |
76 |
218 |
4403200 |
|
2000 |
69941084 |
cor001 |
D |
Feb. 1, 2020, 6:10 a.m. |
OK |
GNU C++11 |
TESTS |
76 |
218 |
4403200 |
|
2000 |
57904304 |
lopare |
D |
July 28, 2019, 4:59 p.m. |
OK |
GNU C++11 |
TESTS |
76 |
218 |
4608000 |
|
2000 |
45158763 |
Sodaine |
D |
Nov. 1, 2018, 6:57 a.m. |
OK |
GNU C++11 |
TESTS |
76 |
218 |
5120000 |
|
2000 |
11097516 |
ikbal |
D |
May 14, 2015, 11:23 a.m. |
OK |
GNU C++11 |
TESTS |
76 |
218 |
5324800 |
|
2000 |
14849617 |
Temirulan |
D |
Dec. 17, 2015, 5:59 p.m. |
OK |
GNU C++11 |
TESTS |
76 |
218 |
5529600 |
|
2000 |
29853669 |
Egor.Lifar |
D |
Aug. 28, 2017, 8:07 p.m. |
OK |
GNU C++14 |
TESTS |
76 |
124 |
4300800 |
|
2000 |
42113389 |
Kepperoni |
D |
Aug. 26, 2018, 7:53 a.m. |
OK |
GNU C++14 |
TESTS |
76 |
186 |
4505600 |
|
2000 |
56017712 |
sorry_im_smurfing |
D |
June 24, 2019, 11 p.m. |
OK |
GNU C++14 |
TESTS |
76 |
216 |
4198400 |
|
2000 |
34566864 |
Aidos |
D |
Jan. 26, 2018, 6:37 a.m. |
OK |
GNU C++14 |
TESTS |
76 |
218 |
6656000 |
|
2000 |
32909492 |
-Morass- |
D |
Dec. 3, 2017, 10:38 p.m. |
OK |
GNU C++14 |
TESTS |
76 |
218 |
6656000 |
|
2000 |
45447488 |
ductuanlhp |
D |
Nov. 8, 2018, 2:08 p.m. |
OK |
GNU C++14 |
TESTS |
76 |
248 |
4812800 |
|
2000 |
28544310 |
sunny000 |
D |
July 14, 2017, 9:32 a.m. |
OK |
GNU C++14 |
TESTS |
76 |
248 |
5017600 |
|
2000 |
43360471 |
w446506278 |
D |
Sept. 24, 2018, 8:59 a.m. |
OK |
GNU C++14 |
TESTS |
76 |
248 |
5120000 |
|
2000 |
39505884 |
Cmise |
D |
June 22, 2018, 4:56 a.m. |
OK |
GNU C++14 |
TESTS |
76 |
248 |
5222400 |
|
2000 |
39811416 |
I_love_Y_UME |
D |
July 1, 2018, 3:33 a.m. |
OK |
GNU C++14 |
TESTS |
76 |
248 |
5222400 |
|
2000 |
56654788 |
vjudge3 |
D |
July 7, 2019, 8:25 a.m. |
OK |
GNU C++17 |
TESTS |
76 |
216 |
9011200 |
|
2000 |
55226516 |
tnakao |
D |
June 7, 2019, 2:03 a.m. |
OK |
GNU C++17 |
TESTS |
76 |
218 |
3276800 |
|
2000 |
42211034 |
.__. |
D |
Aug. 28, 2018, 2:18 p.m. |
OK |
GNU C++17 |
TESTS |
76 |
248 |
5427200 |
|
2000 |
40569866 |
ruo |
D |
July 20, 2018, 7:33 a.m. |
OK |
GNU C++17 |
TESTS |
76 |
248 |
5632000 |
|
2000 |
42132289 |
Gediminas |
D |
Aug. 26, 2018, 7:06 p.m. |
OK |
GNU C++17 |
TESTS |
76 |
248 |
10547200 |
|
2000 |
62870736 |
Leafy_ |
D |
Oct. 18, 2019, 1:41 p.m. |
OK |
GNU C++17 |
TESTS |
76 |
278 |
5222400 |
|
2000 |
66192604 |
SYury |
D |
Dec. 2, 2019, 5:05 p.m. |
OK |
GNU C++17 |
TESTS |
76 |
278 |
8294400 |
|
2000 |
49111881 |
crathva |
D |
Jan. 28, 2019, 3:17 p.m. |
OK |
GNU C++17 |
TESTS |
76 |
280 |
7577600 |
|
2000 |
54174728 |
Curnurx |
D |
May 15, 2019, 1:20 p.m. |
OK |
GNU C++17 |
TESTS |
76 |
310 |
5836800 |
|
2000 |
61397020 |
vjudge5 |
D |
Sept. 28, 2019, 2:56 a.m. |
OK |
GNU C++17 |
TESTS |
76 |
312 |
12390400 |
|
2000 |
649049 |
bjin |
D |
Aug. 29, 2011, 5:54 p.m. |
OK |
Haskell |
TESTS |
76 |
480 |
27340800 |
|
2000 |
648830 |
uwi |
D |
Aug. 29, 2011, 5:49 p.m. |
OK |
Java 6 |
TESTS |
76 |
300 |
35532800 |
|
2000 |
646837 |
niyaznigmatul |
D |
Aug. 29, 2011, 5:01 p.m. |
OK |
Java 6 |
TESTS |
76 |
310 |
35532800 |
|
2000 |
649472 |
alexander.yuriev |
D |
Aug. 29, 2011, 6:48 p.m. |
OK |
Java 6 |
TESTS |
76 |
340 |
35532800 |
|
2000 |
648107 |
yaro |
D |
Aug. 29, 2011, 5:32 p.m. |
OK |
Java 6 |
TESTS |
76 |
380 |
35635200 |
|
2000 |
711760 |
alexey.enkov |
D |
Aug. 29, 2011, 5:30 p.m. |
OK |
Java 6 |
TESTS |
76 |
390 |
35942400 |
|
2000 |
649168 |
shilov |
D |
Aug. 29, 2011, 5:56 p.m. |
OK |
Java 6 |
TESTS |
76 |
420 |
53452800 |
|
2000 |
652635 |
anhdt |
D |
Aug. 30, 2011, 4:42 p.m. |
OK |
Java 6 |
TESTS |
76 |
420 |
59904000 |
|
2000 |
648420 |
mmaxio |
D |
Aug. 29, 2011, 5:39 p.m. |
OK |
Java 6 |
TESTS |
76 |
500 |
44339200 |
|
2000 |
648287 |
Sergey.Bankevich |
D |
Aug. 29, 2011, 5:36 p.m. |
OK |
Java 6 |
TESTS |
76 |
520 |
55603200 |
|
2000 |
649760 |
chavit |
D |
Aug. 29, 2011, 7:05 p.m. |
OK |
Java 6 |
TESTS |
76 |
520 |
62771200 |
|
2000 |
59233845 |
Dukkha |
D |
Aug. 21, 2019, 4:36 p.m. |
OK |
Java 8 |
TESTS |
76 |
810 |
0 |
|
2000 |
61397944 |
vjudge2 |
D |
Sept. 28, 2019, 3:32 a.m. |
OK |
Java 8 |
TESTS |
76 |
2432 |
41676800 |
|
2000 |
8865741 |
AlexFetisov |
D |
Nov. 27, 2014, 4:08 a.m. |
OK |
Java 8 |
TESTS |
76 |
2838 |
13209600 |
|
2000 |
649090 |
ArchMaG |
D |
Aug. 29, 2011, 5:55 p.m. |
OK |
Mono C# |
TESTS |
76 |
840 |
20070400 |
|
2000 |
667337 |
AlphaStream |
D |
Sept. 4, 2011, 10:09 a.m. |
OK |
Mono C# |
TESTS |
76 |
1030 |
21708800 |
|
2000 |
667365 |
AlphaStream |
D |
Sept. 4, 2011, 10:19 a.m. |
OK |
Mono C# |
TESTS |
76 |
1030 |
24985600 |
|
2000 |
31890325 |
totaku |
D |
Oct. 30, 2017, 10:40 a.m. |
OK |
MS C# |
TESTS |
76 |
1122 |
23552000 |
|
2000 |
648409 |
Nyatl |
D |
Aug. 29, 2011, 5:39 p.m. |
OK |
MS C++ |
TESTS |
76 |
160 |
6963200 |
|
2000 |
645683 |
bayleef |
D |
Aug. 29, 2011, 4:39 p.m. |
OK |
MS C++ |
TESTS |
76 |
160 |
17305600 |
|
2000 |
649515 |
e-maxx |
D |
Aug. 29, 2011, 6:53 p.m. |
OK |
MS C++ |
TESTS |
76 |
170 |
6041600 |
|
2000 |
61455469 |
vjudge5 |
D |
Sept. 29, 2019, 6:01 a.m. |
OK |
MS C++ |
TESTS |
76 |
186 |
7680000 |
|
2000 |
645803 |
Jacob |
D |
Aug. 29, 2011, 4:41 p.m. |
OK |
MS C++ |
TESTS |
76 |
190 |
5734400 |
|
2000 |
646718 |
alger95 |
D |
Aug. 29, 2011, 4:59 p.m. |
OK |
MS C++ |
TESTS |
76 |
190 |
5836800 |
|
2000 |
651470 |
Slevin |
D |
Aug. 30, 2011, 6:55 a.m. |
OK |
MS C++ |
TESTS |
76 |
190 |
5836800 |
|
2000 |
648553 |
Polichka |
D |
Aug. 29, 2011, 5:43 p.m. |
OK |
MS C++ |
TESTS |
76 |
190 |
5836800 |
|
2000 |
647674 |
Milanin |
D |
Aug. 29, 2011, 5:21 p.m. |
OK |
MS C++ |
TESTS |
76 |
200 |
5017600 |
|
2000 |
647907 |
Oleg805 |
D |
Aug. 29, 2011, 5:27 p.m. |
OK |
MS C++ |
TESTS |
76 |
200 |
5427200 |
|
2000 |
62036789 |
vjudge2 |
D |
Oct. 7, 2019, 4:14 a.m. |
OK |
MS C++ 2017 |
TESTS |
76 |
248 |
6963200 |
|
2000 |
654729 |
Martial |
D |
Sept. 1, 2011, 12:55 p.m. |
OK |
Python 2 |
TESTS |
76 |
840 |
19456000 |
|
2000 |
654734 |
Martial |
D |
Sept. 1, 2011, 12:59 p.m. |
OK |
Python 2 |
TESTS |
76 |
860 |
19353600 |
|
2000 |
654724 |
Martial |
D |
Sept. 1, 2011, 12:53 p.m. |
OK |
Python 2 |
TESTS |
76 |
860 |
19456000 |
|
2000 |
7275565 |
vjudge4 |
D |
July 28, 2014, 8:15 a.m. |
OK |
Python 2 |
TESTS |
76 |
1340 |
18022400 |
|
2000 |
69944040 |
cor001 |
D |
Feb. 1, 2020, 7:03 a.m. |
OK |
Python 3 |
TESTS |
76 |
1184 |
23244800 |
|
2000 |
remove filters
Back to search problems