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"There are two strings s and t, consisting only of letters a and b. You can make the following operation several times: choose a prefix of s, a prefix of t and swap them. Prefixes can be empty, also a prefix can coincide with a whole string. Your task is to find a sequence of operations after which one of the strings consists only of a letters and the other consists only of b letters. The number of operations should be minimized. The first line contains a string s (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89|s| xe2 x80 x89 xe2 x89 xa4 xe2 x80 x892 xc2 xb7105). The second line contains a string t (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89|t| xe2 x80 x89 xe2 x89 xa4 xe2 x80 x892 xc2 xb7105). Here |s| and |t| denote the lengths of s and t, respectively. It is guaranteed that at least one of the strings contains at least one a letter and at least one of the strings contains at least one b letter. The first line should contain a single integer n (0 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x895 xc2 xb7105) -- the number of operations. Each of the next n lines should contain two space-separated integers ai, bi -- the lengths of prefixes of s and t to swap, respectively. If there are multiple possible solutions, you can print any of them. It's guaranteed that a solution with given constraints exists. In the first example, you can solve the problem in two operations: In the second example, the strings are already appropriate, so no operations are needed. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
40979236 |
Gassa |
D |
July 30, 2018, 4:59 p.m. |
OK |
D |
TESTS |
78 |
483 |
42086400 |
|
2700 |
40979273 |
Gassa |
D |
July 30, 2018, 5 p.m. |
OK |
D |
TESTS |
78 |
592 |
52633600 |
|
2700 |
40966358 |
Gassa |
D |
July 30, 2018, 10:40 a.m. |
OK |
D |
TESTS |
77 |
624 |
52633600 |
|
2700 |
40992361 |
MarkF |
D |
July 31, 2018, 1:16 a.m. |
OK |
GNU C++ |
TESTS |
78 |
93 |
5120000 |
|
2700 |
41002460 |
616156 |
D |
July 31, 2018, 7:51 a.m. |
OK |
GNU C++ |
TESTS |
78 |
93 |
8806400 |
|
2700 |
40969417 |
Serval |
D |
July 30, 2018, 12:41 p.m. |
OK |
GNU C++ |
TESTS |
77 |
93 |
15872000 |
|
2700 |
41616363 |
luogu_bot5 |
D |
Aug. 15, 2018, 9:24 a.m. |
OK |
GNU C++ |
TESTS |
78 |
93 |
22016000 |
|
2700 |
41157423 |
WhiteAlbum |
D |
Aug. 3, 2018, 1:04 p.m. |
OK |
GNU C++ |
TESTS |
78 |
93 |
22016000 |
|
2700 |
41004722 |
zhouzhendong |
D |
July 31, 2018, 9:03 a.m. |
OK |
GNU C++ |
TESTS |
78 |
108 |
22016000 |
|
2700 |
41010614 |
lezdzh |
D |
July 31, 2018, 12:26 p.m. |
OK |
GNU C++ |
TESTS |
78 |
109 |
17100800 |
|
2700 |
41296212 |
WhiteAlbum |
D |
Aug. 7, 2018, 7:21 a.m. |
OK |
GNU C++ |
TESTS |
78 |
109 |
22016000 |
|
2700 |
41194608 |
AMnu |
D |
Aug. 3, 2018, 10:48 p.m. |
OK |
GNU C++ |
TESTS |
78 |
234 |
21196800 |
|
2700 |
41127879 |
Mr.Universe |
D |
Aug. 2, 2018, 3:15 p.m. |
OK |
GNU C++ |
TESTS |
78 |
592 |
5120000 |
|
2700 |
52630550 |
dushaolong |
D |
April 12, 2019, 6:48 a.m. |
OK |
GNU C++11 |
TESTS |
78 |
78 |
7884800 |
|
2700 |
41206362 |
Diego1149 |
D |
Aug. 4, 2018, 8:03 a.m. |
OK |
GNU C++11 |
TESTS |
78 |
93 |
5632000 |
|
2700 |
54506614 |
WOSHIGEPACHONG2 |
D |
May 23, 2019, 4:25 a.m. |
OK |
GNU C++11 |
TESTS |
78 |
93 |
7884800 |
|
2700 |
52630432 |
SYCstudio |
D |
April 12, 2019, 6:44 a.m. |
OK |
GNU C++11 |
TESTS |
78 |
93 |
7884800 |
|
2700 |
49522778 |
frodakcin |
D |
Feb. 6, 2019, 9:16 a.m. |
OK |
GNU C++11 |
TESTS |
78 |
93 |
7987200 |
|
2700 |
61405126 |
ymz |
D |
Sept. 28, 2019, 6:46 a.m. |
OK |
GNU C++11 |
TESTS |
78 |
93 |
11059200 |
|
2700 |
55677383 |
luogu_bot1 |
D |
June 17, 2019, 11:12 a.m. |
OK |
GNU C++11 |
TESTS |
78 |
93 |
22016000 |
|
2700 |
41000388 |
cuizhuyefei |
D |
July 31, 2018, 6:49 a.m. |
OK |
GNU C++11 |
TESTS |
78 |
93 |
36147200 |
|
2700 |
40969731 |
BigBag |
D |
July 30, 2018, 12:46 p.m. |
OK |
GNU C++11 |
TESTS |
77 |
109 |
5017600 |
|
2700 |
40969621 |
BigBag |
D |
July 30, 2018, 12:44 p.m. |
OK |
GNU C++11 |
TESTS |
77 |
109 |
5017600 |
|
2700 |
46917705 |
aid |
D |
Dec. 11, 2018, 10:55 p.m. |
OK |
GNU C++14 |
TESTS |
78 |
93 |
5222400 |
|
2700 |
40987420 |
Motarack |
D |
July 30, 2018, 9:14 p.m. |
OK |
GNU C++14 |
TESTS |
78 |
93 |
7680000 |
|
2700 |
40997526 |
DOlaBMOon |
D |
July 31, 2018, 5:08 a.m. |
OK |
GNU C++14 |
TESTS |
78 |
93 |
7884800 |
|
2700 |
41335774 |
DEMOPON |
D |
Aug. 8, 2018, 11:58 a.m. |
OK |
GNU C++14 |
TESTS |
78 |
93 |
8704000 |
|
2700 |
40997505 |
tmwilliamlin168 |
D |
July 31, 2018, 5:07 a.m. |
OK |
GNU C++14 |
TESTS |
78 |
93 |
8704000 |
|
2700 |
53862970 |
RNS_CUS |
D |
May 7, 2019, 11:31 p.m. |
OK |
GNU C++14 |
TESTS |
78 |
93 |
8806400 |
|
2700 |
53862932 |
RNS_CUS |
D |
May 7, 2019, 11:25 p.m. |
OK |
GNU C++14 |
TESTS |
78 |
93 |
8806400 |
|
2700 |
55857736 |
Scut82 |
D |
June 21, 2019, 7:53 a.m. |
OK |
GNU C++14 |
TESTS |
78 |
93 |
11161600 |
|
2700 |
40963296 |
Ra16bit |
D |
July 30, 2018, 10:12 a.m. |
OK |
GNU C++14 |
TESTS |
77 |
108 |
1228800 |
|
2700 |
40968401 |
traxex |
D |
July 30, 2018, 12:23 p.m. |
OK |
GNU C++14 |
TESTS |
77 |
108 |
7372800 |
|
2700 |
42321696 |
yujinwunz |
D |
Aug. 31, 2018, 10:12 p.m. |
OK |
GNU C++17 |
TESTS |
78 |
77 |
8908800 |
|
2700 |
41003209 |
zhouzhendong |
D |
July 31, 2018, 8:15 a.m. |
OK |
GNU C++17 |
TESTS |
78 |
78 |
22016000 |
|
2700 |
41004129 |
zhouzhendong |
D |
July 31, 2018, 8:46 a.m. |
OK |
GNU C++17 |
TESTS |
78 |
92 |
22016000 |
|
2700 |
41560478 |
cristian1997 |
D |
Aug. 13, 2018, 1:56 p.m. |
OK |
GNU C++17 |
TESTS |
78 |
93 |
2457600 |
|
2700 |
40977102 |
bazsi700 |
D |
July 30, 2018, 4:02 p.m. |
OK |
GNU C++17 |
TESTS |
78 |
93 |
6553600 |
|
2700 |
40976942 |
ReaLNero1 |
D |
July 30, 2018, 3:57 p.m. |
OK |
GNU C++17 |
TESTS |
78 |
93 |
8908800 |
|
2700 |
40960627 |
LHiC |
D |
July 30, 2018, 9:49 a.m. |
OK |
GNU C++17 |
TESTS |
77 |
93 |
8908800 |
|
2700 |
40963025 |
ko_osaga |
D |
July 30, 2018, 10:10 a.m. |
OK |
GNU C++17 |
TESTS |
77 |
93 |
12185600 |
|
2700 |
40996758 |
ghostfly233 |
D |
July 31, 2018, 4:30 a.m. |
OK |
GNU C++17 |
TESTS |
78 |
93 |
15257600 |
|
2700 |
40969127 |
tEMMIE.w. |
D |
July 30, 2018, 12:36 p.m. |
OK |
GNU C++17 |
TESTS |
77 |
93 |
20070400 |
|
2700 |
40980862 |
mmaxio |
D |
July 30, 2018, 5:44 p.m. |
OK |
Java 8 |
TESTS |
78 |
296 |
14131200 |
|
2700 |
40971634 |
qoo2p5 |
D |
July 30, 2018, 1:26 p.m. |
OK |
Java 8 |
TESTS |
78 |
436 |
36352000 |
|
2700 |
40965676 |
uwi |
D |
July 30, 2018, 10:34 a.m. |
OK |
Java 8 |
TESTS |
77 |
639 |
72089600 |
|
2700 |
41042969 |
vadimmm |
D |
July 31, 2018, 3:31 p.m. |
OK |
Java 8 |
TESTS |
78 |
763 |
57651200 |
|
2700 |
40975698 |
waltz |
D |
July 30, 2018, 3:19 p.m. |
OK |
MS C++ |
TESTS |
78 |
93 |
7270400 |
|
2700 |
40968870 |
almogwald |
D |
July 30, 2018, 12:32 p.m. |
OK |
MS C++ |
TESTS |
77 |
701 |
20992000 |
|
2700 |
41274998 |
satja |
D |
Aug. 6, 2018, 12:40 p.m. |
OK |
PyPy 3 |
TESTS |
78 |
935 |
60416000 |
|
2700 |
remove filters
Back to search problems