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'Vasya owns three strings s , a and b , each of them consists only of first k Latin letters. Let a template be such a string of length k that each of the first k Latin letters appears in it exactly once (thus there are k! distinct templates). Application of template p to the string s is the replacement of each character in string s with p_i , i is the index of this letter in the alphabet. For example, applying template "bdca" to a string "aabccd" yields string "bbdcca". Vasya wants to know if there exists such a template which yields a string lexicographically greater than or equal to string a and lexicographically less than or equal to string b after applying it to s . If there exist multiple suitable templates, print any of them. String a is lexicographically less than string b if there is some i ( 1 <= i <= n ) that a_i < b_i and for any j ( 1 <= j < i ) a_j = b_j . You are required to answer t testcases independently. The first line contains a single integer t ( 1 <= t <= 10^6 ) -- the number of testcases. In hacks you can only use t = 1 . Each of the next t lines contains the description of the testcase in the following form: The first line of the testcase contains a single integer k ( 1 <= k <= 26 ) -- the length of the template. The second line of the testcase contains the string s ( 1 <= |s| <= 10^6 ). The third line of the testcase contains the string a . The fourth line of the testcase contains the string b . Strings s , a and b have the same length ( |s| = |a| = |b| ) and consist only of the first k Latin letters, all letters are lowercase. It is guaranteed that string a is lexicographically less than or equal to string b . It is also guaranteed that the total length of strings over all testcase won 't exceed 3 '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
48654231 |
ReaLNero1 |
E |
Jan. 21, 2019, 1:24 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
249 |
8089600 |
|
2500 |
48018957 |
ZqlwMatt |
E |
Jan. 6, 2019, 3:25 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
343 |
75878400 |
|
2500 |
48283653 |
LJC00118 |
E |
Jan. 12, 2019, 9:09 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
545 |
9011200 |
|
2500 |
56145375 |
Sooke |
E |
June 27, 2019, 5:59 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
654 |
2867200 |
|
2500 |
62347957 |
vjudge2 |
E |
Oct. 11, 2019, 8:20 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
701 |
5017600 |
|
2500 |
68369153 |
luogu_bot1 |
E |
Jan. 7, 2020, 5:05 p.m. |
OK |
GNU C++11 |
TESTS |
37 |
717 |
2969600 |
|
2500 |
53905979 |
yyf0309 |
E |
May 9, 2019, 12:45 p.m. |
OK |
GNU C++11 |
TESTS |
37 |
732 |
3993600 |
|
2500 |
49038852 |
vjudge3 |
E |
Jan. 27, 2019, 5:31 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
764 |
2764800 |
|
2500 |
47970040 |
Dilute |
E |
Jan. 5, 2019, 2:09 p.m. |
OK |
GNU C++11 |
TESTS |
37 |
779 |
2969600 |
|
2500 |
52953186 |
xuxuxuxuxu |
E |
April 18, 2019, 12:44 p.m. |
OK |
GNU C++11 |
TESTS |
37 |
779 |
3072000 |
|
2500 |
58921967 |
HouZAJ |
E |
Aug. 16, 2019, 5:37 p.m. |
OK |
GNU C++14 |
TESTS |
37 |
748 |
2969600 |
|
2500 |
58430199 |
_FlyingColor_ |
E |
Aug. 7, 2019, 11:32 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
1075 |
3891200 |
|
2500 |
48092572 |
U_U |
E |
Jan. 8, 2019, 2:40 p.m. |
OK |
GNU C++14 |
TESTS |
37 |
1092 |
15872000 |
|
2500 |
47881810 |
irkstepanov |
E |
Jan. 3, 2019, 6:49 p.m. |
OK |
GNU C++14 |
TESTS |
37 |
1201 |
6246400 |
|
2500 |
48172351 |
zzb111 |
E |
Jan. 10, 2019, 7:31 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
1294 |
2969600 |
|
2500 |
48274558 |
zzb111 |
E |
Jan. 12, 2019, 4:56 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
1310 |
66969600 |
|
2500 |
49302923 |
shamiaomiao |
E |
Feb. 1, 2019, 4:18 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
1325 |
15052800 |
|
2500 |
47431826 |
tmwilliamlin168 |
E |
Dec. 23, 2018, 4:31 p.m. |
OK |
GNU C++14 |
TESTS |
37 |
1512 |
3072000 |
|
2500 |
47506955 |
Demerzel_IV |
E |
Dec. 26, 2018, 1:56 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
1575 |
9011200 |
|
2500 |
47529617 |
aajisaka |
E |
Dec. 26, 2018, 6:02 p.m. |
OK |
GNU C++14 |
TESTS |
37 |
1590 |
259584000 |
|
2500 |
47786323 |
hicodeworld |
E |
Dec. 31, 2018, 10:55 a.m. |
OK |
GNU C++17 |
TESTS |
37 |
1075 |
3891200 |
|
2500 |
47426690 |
AlFlen |
E |
Dec. 23, 2018, 3:19 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
1185 |
3891200 |
|
2500 |
47469982 |
karasek |
E |
Dec. 24, 2018, 9:35 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
1200 |
17305600 |
|
2500 |
62567383 |
_PortgasD.Ace_ |
E |
Oct. 14, 2019, 1:34 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
1387 |
2969600 |
|
2500 |
49889041 |
nickjohn |
E |
Feb. 14, 2019, 1:28 a.m. |
OK |
GNU C++17 |
TESTS |
37 |
1404 |
6963200 |
|
2500 |
48601292 |
zhangqingqi |
E |
Jan. 20, 2019, 8:32 a.m. |
OK |
GNU C++17 |
TESTS |
37 |
1450 |
4300800 |
|
2500 |
52590235 |
HIT_Attacker |
E |
April 11, 2019, 4:57 a.m. |
OK |
GNU C++17 |
TESTS |
37 |
1731 |
3072000 |
|
2500 |
47493391 |
47th-draganov |
E |
Dec. 25, 2018, 1:34 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
1762 |
4300800 |
|
2500 |
52681877 |
nikutto |
E |
April 13, 2019, 12:51 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
1809 |
6348800 |
|
2500 |
68856722 |
vjudge3 |
E |
Jan. 15, 2020, 10:52 a.m. |
OK |
GNU C++17 |
TESTS |
37 |
1887 |
15360000 |
|
2500 |
67011630 |
dalt |
E |
Dec. 16, 2019, 10:04 a.m. |
OK |
Java 8 |
TESTS |
37 |
499 |
148992000 |
|
2500 |
47465981 |
4mda4mda |
E |
Dec. 24, 2018, 6:05 p.m. |
OK |
Java 8 |
TESTS |
37 |
1169 |
10444800 |
|
2500 |
54346655 |
vjudge3 |
E |
May 18, 2019, 12:47 p.m. |
OK |
Java 8 |
TESTS |
37 |
2012 |
18534400 |
|
2500 |
54348225 |
vjudge1 |
E |
May 18, 2019, 1:29 p.m. |
OK |
Java 8 |
TESTS |
37 |
4414 |
8294400 |
|
2500 |
47465603 |
4mda4mda |
E |
Dec. 24, 2018, 5:48 p.m. |
OK |
Java 8 |
TESTS |
37 |
4414 |
8294400 |
|
2500 |
47465967 |
4mda4mda |
E |
Dec. 24, 2018, 6:05 p.m. |
OK |
Java 8 |
TESTS |
37 |
4430 |
10444800 |
|
2500 |
47465771 |
4mda4mda |
E |
Dec. 24, 2018, 5:57 p.m. |
OK |
Java 8 |
TESTS |
37 |
4477 |
8294400 |
|
2500 |
54347604 |
vjudge1 |
E |
May 18, 2019, 1:13 p.m. |
OK |
MS C++ |
TESTS |
37 |
2074 |
15052800 |
|
2500 |
54347379 |
vjudge2 |
E |
May 18, 2019, 1:07 p.m. |
OK |
MS C++ |
TESTS |
37 |
2089 |
15052800 |
|
2500 |
remove filters
Back to search problems