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 a one-dimensional puzzle, all the elements of which need to be put in one row, connecting with each other. All the puzzle elements are completely white and distinguishable from each other only if they have different shapes. Each element has straight borders at the top and bottom, and on the left and right it has connections, each of which can be a protrusion or a recess. You cannot rotate the elements. You can see that there are exactly 4 types of elements. Two elements can be connected if the right connection of the left element is opposite to the left connection of the right element. The puzzle contains c_1, c_2, c_3, c_4 elements of each type. The puzzle is considered complete if you have managed to combine all elements into one long chain. You want to know how many ways this can be done. The first line contains a single integer t ( 1 <= t <= 2 cdot 10^5 ) -- the number of input test cases. The descriptions of the test cases follow. The description of each test case contains 4 integers c_i ( 0 <= c_i <= 10^6 ) -- the number of elements of each type, respectively. It is guaranteed that the sum of c_i for all test cases does not exceed 4 cdot 10^6 . For each test case, print one integer -- the number of possible ways to solve the puzzle. Two methods are considered different if there is i , such that the types of elements at the i position in these methods differ. Since the answer can be very large, output it modulo 998244353 . If it is impossible to solve the puzzle, print 0 . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
246272129 |
SmallXueHua |
G |
Feb. 13, 2024, 6:23 p.m. |
OK |
GNU C++17 |
TESTS |
29 |
46 |
0 |
|
|
246285551 |
Pavlot |
G |
Feb. 13, 2024, 8:29 p.m. |
OK |
GNU C++17 |
TESTS |
29 |
46 |
16076800 |
|
|
246293195 |
liaoli |
G |
Feb. 13, 2024, 10:25 p.m. |
OK |
GNU C++17 |
TESTS |
29 |
61 |
16076800 |
|
|
246262667 |
Coder_Nayak |
G |
Feb. 13, 2024, 5:22 p.m. |
OK |
GNU C++17 |
TESTS |
29 |
62 |
7987200 |
|
|
246312844 |
anant_jain_01 |
G |
Feb. 14, 2024, 5:15 a.m. |
OK |
GNU C++17 |
TESTS |
29 |
62 |
16076800 |
|
|
246312819 |
Papa_Tunde |
G |
Feb. 14, 2024, 5:15 a.m. |
OK |
GNU C++17 |
TESTS |
29 |
62 |
16076800 |
|
|
246307257 |
YeoBL |
G |
Feb. 14, 2024, 3:54 a.m. |
OK |
GNU C++17 |
TESTS |
29 |
62 |
16076800 |
|
|
246301857 |
Jessanosh |
G |
Feb. 14, 2024, 2:13 a.m. |
OK |
GNU C++17 |
TESTS |
29 |
62 |
16076800 |
|
|
246262800 |
kimnattanan |
G |
Feb. 13, 2024, 5:23 p.m. |
OK |
GNU C++17 |
TESTS |
29 |
62 |
16076800 |
|
|
246258724 |
kimnattanan |
G |
Feb. 13, 2024, 5:04 p.m. |
OK |
GNU C++17 |
TESTS |
29 |
62 |
16076800 |
|
|
246282037 |
luckyblock233 |
G |
Feb. 13, 2024, 7:51 p.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
31 |
16076800 |
|
|
246266412 |
Inkyo |
G |
Feb. 13, 2024, 5:44 p.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
31 |
16076800 |
|
|
246314451 |
chwa |
G |
Feb. 14, 2024, 5:35 a.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
46 |
16076800 |
|
|
246273699 |
lakshmankattunga |
G |
Feb. 13, 2024, 6:35 p.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
46 |
16076800 |
|
|
246268496 |
AbbosbekFayzullaev21 |
G |
Feb. 13, 2024, 5:57 p.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
46 |
16076800 |
|
|
246308680 |
Sloan_oneyy |
G |
Feb. 14, 2024, 4:18 a.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
46 |
32051200 |
|
|
246308655 |
Sloan_oneyy |
G |
Feb. 14, 2024, 4:18 a.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
46 |
32051200 |
|
|
246307448 |
naroanah |
G |
Feb. 14, 2024, 3:57 a.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
46 |
32051200 |
|
|
246306192 |
hanime1 |
G |
Feb. 14, 2024, 3:38 a.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
46 |
32051200 |
|
|
246305995 |
Const_int |
G |
Feb. 14, 2024, 3:35 a.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
46 |
32051200 |
|
|
246311277 |
evilboy_ |
G |
Feb. 14, 2024, 4:56 a.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
31 |
0 |
|
|
246311246 |
evilb0y_ |
G |
Feb. 14, 2024, 4:55 a.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
31 |
0 |
|
|
246304512 |
juancs |
G |
Feb. 14, 2024, 3:09 a.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
31 |
7987200 |
|
|
246268386 |
Catee |
G |
Feb. 13, 2024, 5:56 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
31 |
7987200 |
|
|
246298264 |
almeidaraul |
G |
Feb. 14, 2024, 12:32 a.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
31 |
16076800 |
|
|
246278247 |
Mohamed308 |
G |
Feb. 13, 2024, 7:15 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
31 |
16076800 |
|
|
246271938 |
Vania_Javadi |
G |
Feb. 13, 2024, 6:21 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
31 |
16076800 |
|
|
246262183 |
Trigbluy |
G |
Feb. 13, 2024, 5:20 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
31 |
16076800 |
|
|
246258627 |
devangsvaghani |
G |
Feb. 13, 2024, 5:04 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
31 |
16076800 |
|
|
246257898 |
hemanth6 |
G |
Feb. 13, 2024, 5:01 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
31 |
16076800 |
|
|
246298319 |
0x3F |
G |
Feb. 14, 2024, 12:33 a.m. |
OK |
Go |
TESTS |
29 |
62 |
66457600 |
|
|
246298880 |
0x3F |
G |
Feb. 14, 2024, 12:52 a.m. |
OK |
Go |
TESTS |
29 |
77 |
66457600 |
|
|
246298598 |
0x3F |
G |
Feb. 14, 2024, 12:43 a.m. |
OK |
Go |
TESTS |
29 |
77 |
66457600 |
|
|
246292283 |
dzhi |
G |
Feb. 13, 2024, 10:07 p.m. |
OK |
Java 21 |
TESTS |
29 |
343 |
17817600 |
|
|
246301499 |
man-ray |
G |
Feb. 14, 2024, 2:06 a.m. |
OK |
Java 21 |
TESTS |
29 |
343 |
41676800 |
|
|
246291316 |
dzhi |
G |
Feb. 13, 2024, 9:49 p.m. |
OK |
Java 21 |
TESTS |
29 |
358 |
18022400 |
|
|
246301522 |
man-ray |
G |
Feb. 14, 2024, 2:06 a.m. |
OK |
Java 21 |
TESTS |
29 |
404 |
89395200 |
|
|
246308866 |
frey4 |
G |
Feb. 14, 2024, 4:21 a.m. |
OK |
Java 21 |
TESTS |
29 |
436 |
41676800 |
|
|
246260859 |
Dukkha |
G |
Feb. 13, 2024, 5:13 p.m. |
OK |
Java 21 |
TESTS |
29 |
1013 |
58572800 |
|
|
246266186 |
mapleKing |
G |
Feb. 13, 2024, 5:43 p.m. |
OK |
Java 21 |
TESTS |
29 |
1497 |
42393600 |
|
|
246301219 |
powervic08 |
G |
Feb. 14, 2024, 1:58 a.m. |
OK |
Java 21 |
TESTS |
29 |
2464 |
41881600 |
|
|
246301284 |
man-ray |
G |
Feb. 14, 2024, 2 a.m. |
OK |
Java 21 |
TESTS |
29 |
2636 |
42393600 |
|
|
246305145 |
ProjectYoung |
G |
Feb. 14, 2024, 3:21 a.m. |
OK |
Java 8 |
TESTS |
29 |
1435 |
86732800 |
|
|
246262543 |
SlavaG |
G |
Feb. 13, 2024, 5:21 p.m. |
OK |
Kotlin 1.9 |
TESTS |
29 |
342 |
20377600 |
|
|
246276447 |
ahtoh_ |
G |
Feb. 13, 2024, 7 p.m. |
OK |
Node.js |
TESTS |
29 |
311 |
8192000 |
|
|
246266246 |
mymelochan |
G |
Feb. 13, 2024, 5:43 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
218 |
61849600 |
|
|
246287886 |
gardengnome |
G |
Feb. 13, 2024, 8:58 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
218 |
76288000 |
|
|
246267617 |
floweria |
G |
Feb. 13, 2024, 5:52 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
264 |
78540800 |
|
|
246267954 |
floweria |
G |
Feb. 13, 2024, 5:54 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
295 |
84787200 |
|
|
246312735 |
JinYuManTang |
G |
Feb. 14, 2024, 5:14 a.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
296 |
47513600 |
|
|
246266909 |
floweria |
G |
Feb. 13, 2024, 5:47 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
311 |
78028800 |
|
|
246301523 |
Little_Sheep_Yawn |
G |
Feb. 14, 2024, 2:06 a.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
342 |
46694400 |
|
|
246300991 |
Mustela_Erminea |
G |
Feb. 14, 2024, 1:52 a.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
343 |
101990400 |
|
|
246303299 |
Dp_pratyaksh |
G |
Feb. 14, 2024, 2:45 a.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
358 |
10035200 |
|
|
246282436 |
kinglykang |
G |
Feb. 13, 2024, 7:55 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
358 |
10035200 |
|
|
246275419 |
OLOGY |
G |
Feb. 13, 2024, 6:50 p.m. |
OK |
Python 2 |
TESTS |
29 |
3307 |
124518400 |
|
|
246281689 |
OLOGY |
G |
Feb. 13, 2024, 7:48 p.m. |
OK |
Python 2 |
TESTS |
29 |
3337 |
124518400 |
|
|
246311414 |
2110030204 |
G |
Feb. 14, 2024, 4:57 a.m. |
OK |
Python 3 |
TESTS |
29 |
748 |
81100800 |
|
|
246300078 |
bayibo |
G |
Feb. 14, 2024, 1:27 a.m. |
OK |
Python 3 |
TESTS |
29 |
967 |
1228800 |
|
|
246300389 |
luogu_bot5 |
G |
Feb. 14, 2024, 1:37 a.m. |
OK |
Python 3 |
TESTS |
29 |
997 |
1228800 |
|
|
remove filters
Back to search problems