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'Given an undirected connected graph with n vertices and m edges. The graph contains no loops (edges from a vertex to itself) and multiple edges (i.e. no more than one edge between each pair of vertices). The vertices of the graph are numbered from 1 to n . Find the number of paths from a vertex s to t whose length differs from the shortest path from s to t by no more than 1 . It is necessary to consider all suitable paths, even if they pass through the same vertex or edge more than once (i.e. they are not simple). For example, let n = 6 , m = 8 , s = 6 and t = 1 , and let the graph look like the figure above. Then the length of the shortest path from s to t is 1 . Consider all paths whose length is at most 1 + 1 = 2 . There is a total of 4 of matching paths. The first line of test contains the number t ( 1 <= t <= 10^4 ) --the number of test cases in the test. Before each test case, there is a blank line. The first line of test case contains two numbers n, m ( 2 <= n <= 2 cdot 10^5 , 1 <= m <= 2 cdot 10^5 ) --the number of vertices and edges in the graph. The second line contains two numbers s and t ( 1 <= s, t <= n , s neq t ) --the numbers of the start and end vertices of the path. The following m lines contain descriptions of edges: the i th line contains two integers u_i , v_i ( 1 <= u_i,v_i <= n ) -- the numbers of vertices that connect the i th edge. It is guaranteed that the graph is connected and does not contain loops and multiple edges. It is guaranteed that the sum of values n on all test cases of input data does not exceed 2 cdot 10^5 . Similarly, it is guaranteed that the sum of values m on all test cases of input data does not exceed 2 cdot 10^5 . For each test case, output a single number -- the number of paths from '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
148948791 |
BARBARIANNNNN |
G |
March 9, 2022, 5:34 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
124 |
10240000 |
|
|
148939355 |
meyi |
G |
March 9, 2022, 2:43 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
124 |
11468800 |
|
|
148904156 |
Valters07 |
G |
March 8, 2022, 4:42 p.m. |
OK |
GNU C++14 |
TESTS |
29 |
139 |
14028800 |
|
|
148908217 |
SieuPhanDong |
G |
March 8, 2022, 4:52 p.m. |
OK |
GNU C++14 |
TESTS |
29 |
140 |
13312000 |
|
|
148936211 |
Z_i_X |
G |
March 9, 2022, 1:17 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
140 |
17203200 |
|
|
148916386 |
TwentyOneHundredOrBust |
G |
March 8, 2022, 5:55 p.m. |
OK |
GNU C++14 |
TESTS |
29 |
140 |
21401600 |
|
|
148940227 |
Irene |
G |
March 9, 2022, 3:02 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
155 |
13926400 |
|
|
148935717 |
Back05 |
G |
March 9, 2022, 1:01 a.m. |
OK |
GNU C++14 |
TESTS |
49 |
155 |
13926400 |
|
|
148931120 |
Bedo_Sayed |
G |
March 8, 2022, 9:58 p.m. |
OK |
GNU C++14 |
TESTS |
49 |
155 |
15155200 |
|
|
148902548 |
LovelyEther |
G |
March 8, 2022, 4:38 p.m. |
OK |
GNU C++14 |
TESTS |
29 |
156 |
11059200 |
|
|
148941286 |
Srymaker |
G |
March 9, 2022, 3:23 a.m. |
OK |
GNU C++17 |
TESTS |
49 |
77 |
8192000 |
|
|
148942515 |
fym |
G |
March 9, 2022, 3:48 a.m. |
OK |
GNU C++17 |
TESTS |
49 |
109 |
11878400 |
|
|
148939708 |
fym |
G |
March 9, 2022, 2:51 a.m. |
OK |
GNU C++17 |
TESTS |
49 |
124 |
10035200 |
|
|
148939158 |
fym |
G |
March 9, 2022, 2:39 a.m. |
OK |
GNU C++17 |
TESTS |
49 |
124 |
10956800 |
|
|
148905864 |
Jackylkk2003 |
G |
March 8, 2022, 4:46 p.m. |
OK |
GNU C++17 |
TESTS |
29 |
124 |
10956800 |
|
|
148904954 |
kamilszymczak1 |
G |
March 8, 2022, 4:44 p.m. |
OK |
GNU C++17 |
TESTS |
29 |
124 |
11571200 |
|
|
148942580 |
fym |
G |
March 9, 2022, 3:50 a.m. |
OK |
GNU C++17 |
TESTS |
49 |
124 |
11673600 |
|
|
148917328 |
A35 |
G |
March 8, 2022, 6:06 p.m. |
OK |
GNU C++17 |
TESTS |
29 |
124 |
12800000 |
|
|
148927905 |
maIlick630 |
G |
March 8, 2022, 8:45 p.m. |
OK |
GNU C++17 |
TESTS |
29 |
124 |
13721600 |
|
|
148941885 |
fym |
G |
March 9, 2022, 3:36 a.m. |
OK |
GNU C++17 |
TESTS |
49 |
124 |
13926400 |
|
|
148911158 |
JohanWOW |
G |
March 8, 2022, 5:10 p.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
124 |
12492800 |
|
|
148942094 |
xiaolaogou |
G |
March 9, 2022, 3:40 a.m. |
OK |
GNU C++17 (64) |
TESTS |
49 |
139 |
16486400 |
|
|
148942257 |
Rekaxem |
G |
March 9, 2022, 3:43 a.m. |
OK |
GNU C++17 (64) |
TESTS |
49 |
140 |
16793600 |
|
|
148933321 |
kal013 |
G |
March 8, 2022, 11:39 p.m. |
OK |
GNU C++17 (64) |
TESTS |
49 |
140 |
18124800 |
|
|
148905478 |
bokusunny |
G |
March 8, 2022, 4:45 p.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
155 |
14233600 |
|
|
148934670 |
Artemis_Bow |
G |
March 9, 2022, 12:28 a.m. |
OK |
GNU C++17 (64) |
TESTS |
49 |
155 |
14950400 |
|
|
148940836 |
emorgan5289 |
G |
March 9, 2022, 3:15 a.m. |
OK |
GNU C++17 (64) |
TESTS |
49 |
155 |
15257600 |
|
|
148920749 |
rgnerdplayer |
G |
March 8, 2022, 6:48 p.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
155 |
16281600 |
|
|
148910550 |
Temmie |
G |
March 8, 2022, 5:06 p.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
155 |
20172800 |
|
|
148919280 |
Thallium54 |
G |
March 8, 2022, 6:29 p.m. |
OK |
GNU C++17 (64) |
TESTS |
29 |
155 |
20275200 |
|
|
148909822 |
wangtushan |
G |
March 8, 2022, 5:01 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
93 |
18534400 |
|
|
148914245 |
AHF |
G |
March 8, 2022, 5:35 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
109 |
14848000 |
|
|
148909933 |
katoli_3 |
G |
March 8, 2022, 5:02 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
124 |
13414400 |
|
|
148922295 |
Denisov |
G |
March 8, 2022, 7:11 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
124 |
14131200 |
|
|
148915225 |
jiangly |
G |
March 8, 2022, 5:44 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
124 |
15052800 |
|
|
148912775 |
Makcum888 |
G |
March 8, 2022, 5:22 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
124 |
16691200 |
|
|
148940481 |
Dog_food_is_me |
G |
March 9, 2022, 3:08 a.m. |
OK |
GNU C++20 (64) |
TESTS |
49 |
124 |
16793600 |
|
|
148935713 |
inluminas |
G |
March 9, 2022, 1:01 a.m. |
OK |
GNU C++20 (64) |
TESTS |
49 |
124 |
18841600 |
|
|
148926688 |
Grapeee |
G |
March 8, 2022, 8:23 p.m. |
OK |
GNU C++20 (64) |
TESTS |
29 |
124 |
23347200 |
|
|
148944097 |
tarjen |
G |
March 9, 2022, 4:19 a.m. |
OK |
GNU C++20 (64) |
TESTS |
49 |
124 |
25292800 |
|
|
148906566 |
STommydx |
G |
March 8, 2022, 4:48 p.m. |
OK |
Go |
TESTS |
29 |
139 |
20480000 |
|
|
148904798 |
STommydx |
G |
March 8, 2022, 4:44 p.m. |
OK |
Go |
TESTS |
29 |
171 |
22425600 |
|
|
148918529 |
YahiaSherif |
G |
March 8, 2022, 6:20 p.m. |
OK |
Java 11 |
TESTS |
29 |
623 |
40243200 |
|
|
148943793 |
The_terminator |
G |
March 9, 2022, 4:13 a.m. |
OK |
Java 11 |
TESTS |
49 |
702 |
72089600 |
|
|
148938168 |
BadabooBadabee |
G |
March 9, 2022, 2:13 a.m. |
OK |
Java 11 |
TESTS |
49 |
873 |
63283200 |
|
|
148915733 |
adi_7861 |
G |
March 8, 2022, 5:49 p.m. |
OK |
Java 8 |
TESTS |
29 |
389 |
34099200 |
|
|
148923393 |
Golovanov399 |
G |
March 8, 2022, 7:28 p.m. |
OK |
Kotlin 1.5 |
TESTS |
29 |
733 |
33075200 |
|
|
148911607 |
LeoPro |
G |
March 8, 2022, 5:13 p.m. |
OK |
Kotlin 1.5 |
TESTS |
29 |
1060 |
68812800 |
|
|
148919255 |
sdr04055 |
G |
March 8, 2022, 6:29 p.m. |
OK |
MS C++ 2017 |
TESTS |
29 |
826 |
24268800 |
|
|
148922786 |
sushmanth.dampur8780 |
G |
March 8, 2022, 7:18 p.m. |
OK |
PyPy 3 |
TESTS |
29 |
857 |
51097600 |
|
|
148922668 |
abc_2002 |
G |
March 8, 2022, 7:16 p.m. |
OK |
PyPy 3 |
TESTS |
29 |
857 |
51097600 |
|
|
148945492 |
ruimina |
G |
March 9, 2022, 4:45 a.m. |
OK |
PyPy 3 |
TESTS |
49 |
982 |
46080000 |
|
|
148928514 |
titia |
G |
March 8, 2022, 8:58 p.m. |
OK |
PyPy 3 |
TESTS |
29 |
998 |
50380800 |
|
|
148918805 |
Taha1506 |
G |
March 8, 2022, 6:23 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
530 |
52326400 |
|
|
148934586 |
ktthree |
G |
March 9, 2022, 12:26 a.m. |
OK |
PyPy 3-64 |
TESTS |
49 |
1028 |
80691200 |
|
|
148937916 |
Spheniscine |
G |
March 9, 2022, 2:06 a.m. |
OK |
Rust 2021 |
TESTS |
49 |
93 |
24678400 |
|
|
remove filters
Back to search problems