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 is a colony of villains with several holes aligned in a row, where each hole contains exactly one villain. Each colony arrangement can be expressed as a string of even length, where the i -th character of the string represents the type of villain in the i -th hole. Iron Man can destroy a colony only if the colony arrangement is such that all villains of a certain type either live in the first half of the colony or in the second half of the colony. His assistant Jarvis has a special power. It can swap villains of any two holes, i.e. swap any two characters in the string; he can do this operation any number of times. Now Iron Man asks Jarvis q questions. In each question, he gives Jarvis two numbers x and y . Jarvis has to tell Iron Man the number of distinct colony arrangements he can create from the original one using his powers such that all villains having the same type as those originally living in x -th hole or y -th hole live in the same half and the Iron Man can destroy that colony arrangement. Two colony arrangements are considered to be different if there exists a hole such that different types of villains are present in that hole in the arrangements. The first line contains a string s ( 2 <= |s| <= 10^{5} ), representing the initial colony arrangement. String s can have both lowercase and uppercase English letters and its length is even. The second line contains a single integer q ( 1 <= q <= 10^{5} ) -- the number of questions. The i -th of the next q lines contains two integers x_i and y_i ( 1 <= x_i, y_i <= |s| , x_i ne y_i ) -- the two numbers given to the Jarvis for the i -th question. For each question output the number of arrangements possible modulo 10^9+7 . Consider the first example. For the first question, the possible arrangements are "aabb" and "bbaa", and for the second question, index 1 contains 'a ' and in'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
49440945 |
rainboy |
D |
Feb. 3, 2019, 8:58 p.m. |
OK |
GNU C11 |
TESTS |
44 |
764 |
1740800 |
|
2500 |
49645187 |
chandu9100 |
D |
Feb. 9, 2019, 3:36 a.m. |
OK |
GNU C++11 |
TESTS |
44 |
62 |
3379200 |
|
2500 |
49645156 |
redbag |
D |
Feb. 9, 2019, 3:33 a.m. |
OK |
GNU C++11 |
TESTS |
44 |
62 |
3379200 |
|
2500 |
49501316 |
qkoqhh |
D |
Feb. 5, 2019, 3:19 p.m. |
OK |
GNU C++11 |
TESTS |
44 |
62 |
23756800 |
|
2500 |
49548369 |
H-C-H |
D |
Feb. 7, 2019, 2:37 a.m. |
OK |
GNU C++11 |
TESTS |
44 |
78 |
5017600 |
|
2500 |
49446274 |
zlc1114 |
D |
Feb. 4, 2019, 3:22 a.m. |
OK |
GNU C++11 |
TESTS |
44 |
78 |
9113600 |
|
2500 |
49501268 |
qkoqhh |
D |
Feb. 5, 2019, 3:17 p.m. |
OK |
GNU C++11 |
TESTS |
44 |
93 |
45056000 |
|
2500 |
49620235 |
maxtir |
D |
Feb. 8, 2019, 8:59 a.m. |
OK |
GNU C++11 |
TESTS |
44 |
109 |
2560000 |
|
2500 |
49445154 |
cjy2003 |
D |
Feb. 4, 2019, 2:07 a.m. |
OK |
GNU C++11 |
TESTS |
44 |
124 |
1331200 |
|
2500 |
49652429 |
LJC00118 |
D |
Feb. 9, 2019, 8:18 a.m. |
OK |
GNU C++11 |
TESTS |
44 |
124 |
1331200 |
|
2500 |
53701519 |
BestMSN |
D |
May 3, 2019, 10:46 a.m. |
OK |
GNU C++11 |
TESTS |
44 |
124 |
2355200 |
|
2500 |
51246275 |
Nostalgically |
D |
March 13, 2019, 5:30 a.m. |
OK |
GNU C++14 |
TESTS |
44 |
124 |
2457600 |
|
2500 |
54236097 |
vjudge2 |
D |
May 16, 2019, 10:53 a.m. |
OK |
GNU C++14 |
TESTS |
44 |
140 |
1740800 |
|
2500 |
49450858 |
LeeSJm |
D |
Feb. 4, 2019, 7:05 a.m. |
OK |
GNU C++14 |
TESTS |
44 |
140 |
2560000 |
|
2500 |
49453589 |
pekempey |
D |
Feb. 4, 2019, 8:53 a.m. |
OK |
GNU C++14 |
TESTS |
44 |
140 |
11980800 |
|
2500 |
49467753 |
DeadPillow |
D |
Feb. 4, 2019, 3:48 p.m. |
OK |
GNU C++14 |
TESTS |
44 |
155 |
2560000 |
|
2500 |
49643758 |
HatsuneMikuo |
D |
Feb. 9, 2019, 1:45 a.m. |
OK |
GNU C++14 |
TESTS |
44 |
155 |
3072000 |
|
2500 |
49643742 |
interestingLSY |
D |
Feb. 9, 2019, 1:44 a.m. |
OK |
GNU C++14 |
TESTS |
44 |
155 |
3072000 |
|
2500 |
49451918 |
tbzard |
D |
Feb. 4, 2019, 7:46 a.m. |
OK |
GNU C++14 |
TESTS |
44 |
171 |
1740800 |
|
2500 |
49459816 |
akapros |
D |
Feb. 4, 2019, 12:24 p.m. |
OK |
GNU C++14 |
TESTS |
44 |
171 |
1740800 |
|
2500 |
49451234 |
Bartholomew |
D |
Feb. 4, 2019, 7:19 a.m. |
OK |
GNU C++14 |
TESTS |
44 |
171 |
2150400 |
|
2500 |
49462015 |
markotee |
D |
Feb. 4, 2019, 1:27 p.m. |
OK |
GNU C++17 |
TESTS |
44 |
139 |
1331200 |
|
2500 |
49445129 |
tyler |
D |
Feb. 4, 2019, 2:05 a.m. |
OK |
GNU C++17 |
TESTS |
44 |
140 |
1638400 |
|
2500 |
49536772 |
Qingyu |
D |
Feb. 6, 2019, 4:21 p.m. |
OK |
GNU C++17 |
TESTS |
44 |
155 |
2764800 |
|
2500 |
49511486 |
ogo |
D |
Feb. 5, 2019, 8:45 p.m. |
OK |
GNU C++17 |
TESTS |
44 |
171 |
2150400 |
|
2500 |
49465436 |
dsl2002 |
D |
Feb. 4, 2019, 2:52 p.m. |
OK |
GNU C++17 |
TESTS |
44 |
186 |
1536000 |
|
2500 |
50635780 |
oToToT |
D |
March 1, 2019, 11:44 a.m. |
OK |
GNU C++17 |
TESTS |
44 |
187 |
1331200 |
|
2500 |
49528073 |
fake_fake |
D |
Feb. 6, 2019, 12:29 p.m. |
OK |
GNU C++17 |
TESTS |
44 |
187 |
1843200 |
|
2500 |
49445983 |
hfctf0210 |
D |
Feb. 4, 2019, 3:01 a.m. |
OK |
GNU C++17 |
TESTS |
44 |
187 |
2560000 |
|
2500 |
49475385 |
hyper_sinnniy |
D |
Feb. 4, 2019, 7:07 p.m. |
OK |
GNU C++17 |
TESTS |
44 |
187 |
22220800 |
|
2500 |
49473513 |
AakashHanda |
D |
Feb. 4, 2019, 6:16 p.m. |
OK |
GNU C++17 |
TESTS |
44 |
187 |
23449600 |
|
2500 |
49459104 |
savinov |
D |
Feb. 4, 2019, 12:02 p.m. |
OK |
Go |
TESTS |
44 |
514 |
5324800 |
|
2500 |
49510599 |
xodiac |
D |
Feb. 5, 2019, 8:06 p.m. |
OK |
Java 8 |
TESTS |
44 |
405 |
0 |
|
2500 |
49933065 |
Ahmad |
D |
Feb. 15, 2019, 5:53 a.m. |
OK |
Java 8 |
TESTS |
44 |
451 |
0 |
|
2500 |
49440579 |
ZeyadKhattab |
D |
Feb. 3, 2019, 8:46 p.m. |
OK |
Java 8 |
TESTS |
44 |
826 |
0 |
|
2500 |
49617020 |
tmwilliamlin168 |
D |
Feb. 8, 2019, 6:49 a.m. |
OK |
Java 8 |
TESTS |
44 |
1310 |
0 |
|
2500 |
49562906 |
wadissimo |
D |
Feb. 7, 2019, 1:30 p.m. |
OK |
Java 8 |
TESTS |
44 |
1481 |
0 |
|
2500 |
49440946 |
Dukkha |
D |
Feb. 3, 2019, 8:58 p.m. |
OK |
Java 8 |
TESTS |
44 |
1496 |
0 |
|
2500 |
49445930 |
LLI_E_P_JI_O_K |
D |
Feb. 4, 2019, 2:58 a.m. |
OK |
JavaScript |
TESTS |
44 |
889 |
14745600 |
|
2500 |
54998589 |
camypaper |
D |
June 3, 2019, 2:27 a.m. |
OK |
Mono C# |
TESTS |
44 |
826 |
5222400 |
|
2500 |
49528432 |
grey |
D |
Feb. 6, 2019, 12:41 p.m. |
OK |
MS C++ |
TESTS |
44 |
1247 |
7475200 |
|
2500 |
49635803 |
uncerso |
D |
Feb. 8, 2019, 6:38 p.m. |
OK |
MS C++ 2017 |
TESTS |
44 |
467 |
1433600 |
|
2500 |
49521585 |
Thysee |
D |
Feb. 6, 2019, 8:21 a.m. |
OK |
MS C++ 2017 |
TESTS |
44 |
701 |
921600 |
|
2500 |
49483276 |
Bovniova |
D |
Feb. 5, 2019, 2:12 a.m. |
OK |
PyPy 3 |
TESTS |
44 |
1653 |
34201600 |
|
2500 |
49472150 |
Bovniova |
D |
Feb. 4, 2019, 5:36 p.m. |
OK |
PyPy 3 |
TESTS |
44 |
1684 |
34508800 |
|
2500 |
63227052 |
sansen |
D |
Oct. 23, 2019, 9:39 a.m. |
OK |
Rust |
TESTS |
44 |
171 |
5529600 |
|
2500 |
63226705 |
sansen |
D |
Oct. 23, 2019, 9:33 a.m. |
OK |
Rust |
TESTS |
44 |
904 |
5529600 |
|
2500 |
49464453 |
yakamoto |
D |
Feb. 4, 2019, 2:28 p.m. |
OK |
Scala |
TESTS |
44 |
1652 |
0 |
|
2500 |
remove filters
Back to search problems