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 are given a directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u to v . Vertices are numbered from 1 to n . A path from u to v is a sequence of edges such that: We will assume that the empty sequence of edges is a path from u to u . For each vertex v output one of four values: Let's look at the example shown in the figure. Then: The first contains an integer t ( 1 <= t <= 10^4 ) -- the number of test cases in the input. Then t test cases follow. Before each test case, there is an empty line. The first line of the test case contains two integers n and m ( 1 <= n <= 4 cdot 10^5, 0 <= m <= 4 cdot 10^5 ) -- numbers of vertices and edges in graph respectively. The next m lines contain edges descriptions. Each line contains two integers a_i , b_i ( 1 <= a_i, b_i <= n ) -- the start and the end of the i -th edge. The vertices of the graph are numbered from 1 to n . The given graph can contain loops (it is possible that a_i = b_i ), but cannot contain multi-edges (it is not possible that a_i = a_j and b_i = b_j for i ne j ). The sum of n over all test cases does not exceed 4 cdot 10^5 . Similarly, the sum of m over all test cases does not exceed 4 cdot 10^5 . Output t lines. The i -th line should contain an answer for the i -th test case: a sequence of n integers from -1 to 2 . "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
122038107 |
HellollWorld |
G |
July 11, 2021, 5:26 a.m. |
OK |
GNU C++11 |
TESTS |
61 |
171 |
52428800 |
|
|
122012237 |
Crab_Dave |
G |
July 10, 2021, 6:19 p.m. |
OK |
GNU C++11 |
TESTS |
61 |
233 |
32256000 |
|
|
122037754 |
wkywky |
G |
July 11, 2021, 5:19 a.m. |
OK |
GNU C++11 |
TESTS |
61 |
248 |
49664000 |
|
|
122030268 |
ZeesangPie |
G |
July 11, 2021, 2:35 a.m. |
OK |
GNU C++11 |
TESTS |
61 |
249 |
27443200 |
|
|
122030472 |
E-ray |
G |
July 11, 2021, 2:40 a.m. |
OK |
GNU C++11 |
TESTS |
61 |
249 |
41881600 |
|
|
122033444 |
wangyuxianWBWYX |
G |
July 11, 2021, 3:45 a.m. |
OK |
GNU C++11 |
TESTS |
61 |
264 |
27443200 |
|
|
122001253 |
xiaoxiaoshutiao |
G |
July 10, 2021, 4:48 p.m. |
OK |
GNU C++11 |
TESTS |
61 |
264 |
31232000 |
|
|
122026372 |
rky1729 |
G |
July 11, 2021, 12:32 a.m. |
OK |
GNU C++11 |
TESTS |
61 |
311 |
52838400 |
|
|
122027073 |
jzp2006 |
G |
July 11, 2021, 1:01 a.m. |
OK |
GNU C++11 |
TESTS |
61 |
311 |
84889600 |
|
|
122000720 |
moqizhu2005 |
G |
July 10, 2021, 4:47 p.m. |
OK |
GNU C++11 |
TESTS |
61 |
312 |
37683200 |
|
|
122039653 |
boy_of_kutbilim |
G |
July 11, 2021, 5:54 a.m. |
OK |
GNU C++14 |
TESTS |
61 |
265 |
48230400 |
|
|
122039332 |
boy_of_kutbilim |
G |
July 11, 2021, 5:48 a.m. |
OK |
GNU C++14 |
TESTS |
61 |
280 |
38604800 |
|
|
122001687 |
darknight0409 |
G |
July 10, 2021, 4:49 p.m. |
OK |
GNU C++14 |
TESTS |
61 |
296 |
30617600 |
|
|
122009382 |
_shin |
G |
July 10, 2021, 5:46 p.m. |
OK |
GNU C++14 |
TESTS |
61 |
311 |
33792000 |
|
|
122022914 |
Vin__ar |
G |
July 10, 2021, 10:02 p.m. |
OK |
GNU C++14 |
TESTS |
61 |
311 |
34611200 |
|
|
122034464 |
GeZhiyuan |
G |
July 11, 2021, 4:07 a.m. |
OK |
GNU C++14 |
TESTS |
61 |
311 |
40243200 |
|
|
122039240 |
Pradyumna_ |
G |
July 11, 2021, 5:46 a.m. |
OK |
GNU C++14 |
TESTS |
61 |
311 |
49868800 |
|
|
121999975 |
asfd221 |
G |
July 10, 2021, 4:46 p.m. |
OK |
GNU C++14 |
TESTS |
61 |
312 |
35430400 |
|
|
122031641 |
High_Score |
G |
July 11, 2021, 3:06 a.m. |
OK |
GNU C++14 |
TESTS |
61 |
327 |
33792000 |
|
|
122023122 |
Reverent |
G |
July 10, 2021, 10:09 p.m. |
OK |
GNU C++14 |
TESTS |
61 |
327 |
49766400 |
|
|
122035254 |
RickieLukas |
G |
July 11, 2021, 4:25 a.m. |
OK |
GNU C++17 |
TESTS |
61 |
233 |
28262400 |
|
|
122009618 |
0721 |
G |
July 10, 2021, 5:48 p.m. |
OK |
GNU C++17 |
TESTS |
61 |
265 |
23244800 |
|
|
122008784 |
niyuzheNO1 |
G |
July 10, 2021, 5:39 p.m. |
OK |
GNU C++17 |
TESTS |
61 |
265 |
349286400 |
|
|
122026186 |
jamessngg |
G |
July 11, 2021, 12:24 a.m. |
OK |
GNU C++17 |
TESTS |
61 |
280 |
39424000 |
|
|
122038785 |
_comfortably_numb |
G |
July 11, 2021, 5:38 a.m. |
OK |
GNU C++17 |
TESTS |
61 |
280 |
40652800 |
|
|
122014800 |
m_tab |
G |
July 10, 2021, 6:55 p.m. |
OK |
GNU C++17 |
TESTS |
61 |
280 |
41779200 |
|
|
122009470 |
StelaYuri |
G |
July 10, 2021, 5:47 p.m. |
OK |
GNU C++17 |
TESTS |
61 |
296 |
30617600 |
|
|
122036180 |
diyora13 |
G |
July 11, 2021, 4:47 a.m. |
OK |
GNU C++17 |
TESTS |
61 |
296 |
33792000 |
|
|
122009919 |
DDJHB |
G |
July 10, 2021, 5:52 p.m. |
OK |
GNU C++17 |
TESTS |
61 |
296 |
35430400 |
|
|
122024002 |
bonopo |
G |
July 10, 2021, 10:44 p.m. |
OK |
GNU C++17 |
TESTS |
61 |
296 |
40243200 |
|
|
121999703 |
naman1601 |
G |
July 10, 2021, 4:46 p.m. |
OK |
GNU C++17 (64) |
TESTS |
61 |
280 |
52940800 |
|
|
122003727 |
hebtu2019010920kwq |
G |
July 10, 2021, 4:56 p.m. |
OK |
GNU C++17 (64) |
TESTS |
61 |
280 |
59289600 |
|
|
122028688 |
Busan |
G |
July 11, 2021, 1:53 a.m. |
OK |
GNU C++17 (64) |
TESTS |
61 |
280 |
62566400 |
|
|
122027584 |
Wild4Stone |
G |
July 11, 2021, 1:18 a.m. |
OK |
GNU C++17 (64) |
TESTS |
61 |
296 |
44851200 |
|
|
122030099 |
_JY |
G |
July 11, 2021, 2:30 a.m. |
OK |
GNU C++17 (64) |
TESTS |
61 |
311 |
74956800 |
|
|
122037035 |
Tzak |
G |
July 11, 2021, 5:03 a.m. |
OK |
GNU C++17 (64) |
TESTS |
61 |
312 |
59904000 |
|
|
122029197 |
against_the_current |
G |
July 11, 2021, 2:08 a.m. |
OK |
GNU C++17 (64) |
TESTS |
61 |
327 |
51302400 |
|
|
122019034 |
mshiladityam |
G |
July 10, 2021, 8:11 p.m. |
OK |
GNU C++17 (64) |
TESTS |
61 |
327 |
61747200 |
|
|
122003706 |
zark84010 |
G |
July 10, 2021, 4:56 p.m. |
OK |
GNU C++17 (64) |
TESTS |
61 |
327 |
76902400 |
|
|
122012423 |
Narutobaco |
G |
July 10, 2021, 6:21 p.m. |
OK |
GNU C++17 (64) |
TESTS |
61 |
342 |
58470400 |
|
|
122028988 |
uwi |
G |
July 11, 2021, 2:02 a.m. |
OK |
Java 11 |
TESTS |
61 |
545 |
41881600 |
|
|
122017325 |
HBP |
G |
July 10, 2021, 7:36 p.m. |
OK |
Java 11 |
TESTS |
61 |
1746 |
332083200 |
|
|
122000696 |
aminul |
G |
July 10, 2021, 4:47 p.m. |
OK |
Java 11 |
TESTS |
61 |
2620 |
536883200 |
|
|
122016931 |
suVrik |
G |
July 10, 2021, 7:29 p.m. |
OK |
MS C++ 2017 |
TESTS |
61 |
889 |
24883200 |
|
|
122039942 |
marxist |
G |
July 11, 2021, 5:59 a.m. |
OK |
MS C++ 2017 |
TESTS |
61 |
1169 |
49664000 |
|
|
122000365 |
ageprocpp |
G |
July 10, 2021, 4:47 p.m. |
OK |
MS C++ 2017 |
TESTS |
61 |
1340 |
61030400 |
|
|
122020292 |
mban259 |
G |
July 10, 2021, 8:40 p.m. |
OK |
.NET Core C# |
TESTS |
61 |
638 |
133324800 |
|
|
122002505 |
lionvs132 |
G |
July 10, 2021, 4:51 p.m. |
OK |
.NET Core C# |
TESTS |
61 |
1169 |
101478400 |
|
|
122002769 |
lionvs132 |
G |
July 10, 2021, 4:52 p.m. |
OK |
.NET Core C# |
TESTS |
61 |
1200 |
101171200 |
|
|
121998936 |
Mukundan314 |
G |
July 10, 2021, 4:44 p.m. |
OK |
PyPy 2 |
TESTS |
61 |
1013 |
89497600 |
|
|
122021105 |
acorn11 |
G |
July 10, 2021, 9:02 p.m. |
OK |
PyPy 2 |
TESTS |
61 |
2604 |
77312000 |
|
|
122035749 |
not_tehlka |
G |
July 11, 2021, 4:38 a.m. |
OK |
PyPy 3 |
TESTS |
61 |
842 |
57753600 |
|
|
122016297 |
codicon |
G |
July 10, 2021, 7:19 p.m. |
OK |
PyPy 3 |
TESTS |
61 |
2262 |
165171200 |
|
|
122008219 |
The_KingSlayer_ |
G |
July 10, 2021, 5:33 p.m. |
OK |
PyPy 3 |
TESTS |
61 |
2323 |
258457600 |
|
|
121998501 |
huikang |
G |
July 10, 2021, 4:43 p.m. |
OK |
PyPy 3 |
TESTS |
61 |
2323 |
258457600 |
|
|
122016168 |
codicon |
G |
July 10, 2021, 7:16 p.m. |
OK |
PyPy 3 |
TESTS |
61 |
2480 |
165580800 |
|
|
122015876 |
codicon |
G |
July 10, 2021, 7:12 p.m. |
OK |
PyPy 3 |
TESTS |
61 |
3150 |
168038400 |
|
|
122026576 |
augurar |
G |
July 11, 2021, 12:42 a.m. |
OK |
PyPy 3 |
TESTS |
61 |
3680 |
78643200 |
|
|
122008327 |
The_KingSlayer_ |
G |
July 10, 2021, 5:34 p.m. |
OK |
Python 3 |
TESTS |
61 |
1981 |
41881600 |
|
|
122017560 |
sahilrox |
G |
July 10, 2021, 7:40 p.m. |
OK |
Python 3 |
TESTS |
61 |
2401 |
341913600 |
|
|
remove filters
Back to search problems