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'Petr is a detective in Braginsk. Somebody stole a huge amount of money from a bank and Petr is to catch him. Somebody told Petr that some luxurious car moves along the roads without stopping. Petr knows that it is the robbers who drive the car. The roads in Braginsk are one-directional and each of them connects two intersections. Petr wants to select one intersection such that if the robbers continue to drive the roads indefinitely, they will sooner or later come to that intersection. The initial position of the robbers is unknown. Find such an intersection that fits the requirements. The first line of the input contains two integers n and m ( 2 <= q n <= 10^5 , 2 <= q m <= q 5 cdot 10^5 ) -- the number of intersections and the number of directed roads in Braginsk, respectively. Each of the next m lines contains two integers u_i and v_i ( 1 <= u_i, v_i <= n , u_i ne v_i ) -- the start and finish of the i -th directed road. It is guaranteed that the robbers can move along the roads indefinitely. Print a single integer k -- the intersection Petr needs to choose. If there are multiple answers, print any. If there are no such intersections, print -1 . In the first example the robbers can move, for example, along the following routes: (1-2-3-1) , (3-4-5-3) , (1-2-3-4-5-3-1) . We can show that if Petr chooses the 3 -rd intersection, he will eventually meet the robbers independently of their route. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
39737239 |
vjudge5 |
F |
June 28, 2018, 8:46 a.m. |
OK |
GNU C++ |
TESTS |
72 |
499 |
15462400 |
|
2800 |
39730783 |
vjudge5 |
F |
June 28, 2018, 2:16 a.m. |
OK |
GNU C++ |
TESTS |
72 |
514 |
12697600 |
|
2800 |
38386309 |
vosptu |
F |
May 18, 2018, 2:02 a.m. |
OK |
GNU C++ |
TESTS |
72 |
561 |
24576000 |
|
2800 |
38386318 |
vosptu |
F |
May 18, 2018, 2:03 a.m. |
OK |
GNU C++ |
TESTS |
72 |
607 |
24473600 |
|
2800 |
38414587 |
Tgotp |
F |
May 19, 2018, 2:24 a.m. |
OK |
GNU C++ |
TESTS |
72 |
873 |
15769600 |
|
2800 |
38966093 |
hddp |
F |
June 5, 2018, 10:47 a.m. |
OK |
GNU C++ |
TESTS |
72 |
951 |
23040000 |
|
2800 |
38387390 |
Maniac_Wallnut |
F |
May 18, 2018, 3:11 a.m. |
OK |
GNU C++ |
TESTS |
72 |
998 |
9113600 |
|
2800 |
40932104 |
ReaLNero1 |
F |
July 30, 2018, 1:35 a.m. |
OK |
GNU C++11 |
TESTS |
72 |
155 |
42700800 |
|
2800 |
38532911 |
emoairx |
F |
May 22, 2018, 11:16 a.m. |
OK |
GNU C++11 |
TESTS |
72 |
155 |
42700800 |
|
2800 |
38520748 |
251 |
F |
May 22, 2018, 12:58 a.m. |
OK |
GNU C++11 |
TESTS |
72 |
171 |
10649600 |
|
2800 |
50040912 |
xielinhan |
F |
Feb. 17, 2019, 1:46 a.m. |
OK |
GNU C++11 |
TESTS |
72 |
171 |
13414400 |
|
2800 |
38798606 |
a1214034447 |
F |
May 31, 2018, 10:52 a.m. |
OK |
GNU C++11 |
TESTS |
72 |
171 |
46182400 |
|
2800 |
51195700 |
alex_Harry |
F |
March 11, 2019, 6:42 p.m. |
OK |
GNU C++11 |
TESTS |
72 |
186 |
13107200 |
|
2800 |
38522792 |
GuYueNa |
F |
May 22, 2018, 3:38 a.m. |
OK |
GNU C++11 |
TESTS |
72 |
186 |
68812800 |
|
2800 |
38520728 |
251 |
F |
May 22, 2018, 12:56 a.m. |
OK |
GNU C++11 |
TESTS |
72 |
202 |
10649600 |
|
2800 |
42702021 |
_Dispwnl |
F |
Sept. 9, 2018, 11:04 a.m. |
OK |
GNU C++11 |
TESTS |
72 |
202 |
11776000 |
|
2800 |
38566616 |
pornobaron |
F |
May 23, 2018, 3:34 p.m. |
OK |
GNU C++11 |
TESTS |
72 |
202 |
14336000 |
|
2800 |
38538820 |
JHSN |
F |
May 22, 2018, 2:34 p.m. |
OK |
GNU C++14 |
TESTS |
72 |
249 |
11468800 |
|
2800 |
44946767 |
minson123 |
F |
Oct. 27, 2018, 10:14 a.m. |
OK |
GNU C++14 |
TESTS |
72 |
249 |
12902400 |
|
2800 |
44945393 |
minson123 |
F |
Oct. 27, 2018, 9:52 a.m. |
OK |
GNU C++14 |
TESTS |
72 |
249 |
12902400 |
|
2800 |
39228951 |
_Na2Th |
F |
June 14, 2018, 1 a.m. |
OK |
GNU C++14 |
TESTS |
72 |
249 |
18432000 |
|
2800 |
38424487 |
chenyanbo |
F |
May 19, 2018, 9:05 a.m. |
OK |
GNU C++14 |
TESTS |
72 |
264 |
18534400 |
|
2800 |
38867878 |
rdiachenko |
F |
June 1, 2018, 10:24 p.m. |
OK |
GNU C++14 |
TESTS |
72 |
264 |
20377600 |
|
2800 |
68033783 |
bjn.revolution |
F |
Jan. 1, 2020, 10:52 a.m. |
OK |
GNU C++14 |
TESTS |
72 |
265 |
18227200 |
|
2800 |
38764988 |
KeyID |
F |
May 30, 2018, 8:10 a.m. |
OK |
GNU C++14 |
TESTS |
72 |
280 |
13414400 |
|
2800 |
38593111 |
Kurt |
F |
May 24, 2018, 5:20 p.m. |
OK |
GNU C++14 |
TESTS |
72 |
280 |
13516800 |
|
2800 |
38593147 |
Kurt |
F |
May 24, 2018, 5:21 p.m. |
OK |
GNU C++14 |
TESTS |
72 |
280 |
13619200 |
|
2800 |
68379015 |
icecuber |
F |
Jan. 7, 2020, 10:15 p.m. |
OK |
GNU C++17 |
TESTS |
72 |
233 |
13824000 |
|
2800 |
52022236 |
SheepRanger |
F |
March 30, 2019, 1:17 p.m. |
OK |
GNU C++17 |
TESTS |
72 |
233 |
14028800 |
|
2800 |
42260812 |
lintoto |
F |
Aug. 30, 2018, 3:02 a.m. |
OK |
GNU C++17 |
TESTS |
72 |
280 |
11776000 |
|
2800 |
40768066 |
cjnwq |
F |
July 26, 2018, 7:21 a.m. |
OK |
GNU C++17 |
TESTS |
72 |
280 |
15564800 |
|
2800 |
43666989 |
yujinwunz |
F |
Oct. 2, 2018, 12:24 a.m. |
OK |
GNU C++17 |
TESTS |
72 |
280 |
16486400 |
|
2800 |
39056130 |
Jakube |
F |
June 8, 2018, 10:51 p.m. |
OK |
GNU C++17 |
TESTS |
72 |
295 |
17100800 |
|
2800 |
42280190 |
Benq |
F |
Aug. 30, 2018, 1:49 p.m. |
OK |
GNU C++17 |
TESTS |
72 |
296 |
11571200 |
|
2800 |
40670780 |
toxzi |
F |
July 23, 2018, 12:29 p.m. |
OK |
GNU C++17 |
TESTS |
72 |
311 |
15769600 |
|
2800 |
40674459 |
toxzi |
F |
July 23, 2018, 2:32 p.m. |
OK |
GNU C++17 |
TESTS |
72 |
311 |
16793600 |
|
2800 |
38382554 |
kostka |
F |
May 17, 2018, 8:53 p.m. |
OK |
GNU C++17 |
TESTS |
72 |
420 |
9728000 |
|
2800 |
remove filters
Back to search problems