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 graph consisting of n vertices and m edges. It is not guaranteed that the given graph is connected. Some edges are already directed and you can 't change their direction. Other edges are undirected and you have to choose some direction for all these edges. You have to direct undirected edges in such a way that the resulting graph is directed and acyclic (i.e. the graph with all edges directed and having no directed cycles). Note that you have to direct all undirected edges. You have to answer t independent test cases. The first line of the input contains one integer t ( 1 <= t <= 2 cdot 10^4 ) -- the number of test cases. Then t test cases follow. The first line of the test case contains two integers n and m ( 2 <= n <= 2 cdot 10^5 , 1 <= m <= min(2 cdot 10^5, frac{n(n-1)}{2}) ) -- the number of vertices and the number of edges in the graph, respectively. The next m lines describe edges of the graph. The i -th edge is described with three integers t_i , x_i and y_i ( t_i in [0; 1] , 1 <= x_i, y_i <= n ) -- the type of the edge ( t_i = 0 if the edge is undirected and t_i = 1 if the edge is directed) and vertices this edge connects (the undirected edge connects vertices x_i and y_i and directed edge is going from the vertex x_i to the vertex y_i ). It is guaranteed that the graph do not contain self-loops (i.e. edges from the vertex to itself) and multiple edges (i.e. for each pair ( x_i, y_i ) there are no other pairs ( x_i, y_i ) or ( y_i, x_i )). It is guaranteed that both sum n and sum m do not exceed 2 cdot 10^5 ( sum n <= 2 cdot 10^5 ; sum m <= 2 cdot 10^5 ). For each test case print the answer -- "NO" if it is impossible to direct undirected edges in such a way that the resulting graph is directed and acyclic, otherwise print "YES" on the first line a'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
87139440 |
rainboy |
E |
July 17, 2020, 3:56 p.m. |
OK |
GNU C11 |
TESTS |
30 |
889 |
14131200 |
|
2000 |
87125747 |
dysyn1314 |
E |
July 17, 2020, 3:29 p.m. |
OK |
GNU C++11 |
TESTS |
30 |
61 |
13926400 |
|
2000 |
87156547 |
Clouder0 |
E |
July 17, 2020, 4:39 p.m. |
OK |
GNU C++11 |
TESTS |
30 |
109 |
15155200 |
|
2000 |
87171417 |
suxxsfe |
E |
July 17, 2020, 6:25 p.m. |
OK |
GNU C++11 |
TESTS |
30 |
109 |
16691200 |
|
2000 |
87188299 |
YHHxBULIATANIA |
E |
July 18, 2020, 1:47 a.m. |
OK |
GNU C++11 |
TESTS |
30 |
109 |
20070400 |
|
2000 |
87141721 |
xhtyyds |
E |
July 17, 2020, 4:01 p.m. |
OK |
GNU C++11 |
TESTS |
30 |
124 |
21196800 |
|
2000 |
87140555 |
lavenderwithbluish |
E |
July 17, 2020, 3:58 p.m. |
OK |
GNU C++11 |
TESTS |
30 |
124 |
60211200 |
|
2000 |
87155809 |
fengyangyang |
E |
July 17, 2020, 4:37 p.m. |
OK |
GNU C++11 |
TESTS |
30 |
124 |
71884800 |
|
2000 |
87190016 |
hunxuewangzi |
E |
July 18, 2020, 2:34 a.m. |
OK |
GNU C++11 |
TESTS |
30 |
155 |
12697600 |
|
2000 |
87148078 |
Unstoppable728 |
E |
July 17, 2020, 4:16 p.m. |
OK |
GNU C++11 |
TESTS |
30 |
156 |
32870400 |
|
2000 |
87155005 |
4790iop |
E |
July 17, 2020, 4:35 p.m. |
OK |
GNU C++11 |
TESTS |
30 |
186 |
12697600 |
|
2000 |
87128263 |
csc |
E |
July 17, 2020, 3:34 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
186 |
14950400 |
|
2000 |
87194025 |
vitoy |
E |
July 18, 2020, 4:12 a.m. |
OK |
GNU C++14 |
TESTS |
30 |
202 |
13209600 |
|
2000 |
87152439 |
redredredredred |
E |
July 17, 2020, 4:28 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
202 |
15872000 |
|
2000 |
87174647 |
shivam_hbtu |
E |
July 17, 2020, 7:06 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
202 |
16076800 |
|
2000 |
87188419 |
idontreallyknow |
E |
July 18, 2020, 1:51 a.m. |
OK |
GNU C++14 |
TESTS |
30 |
202 |
16179200 |
|
2000 |
87180377 |
unholyspirit |
E |
July 17, 2020, 8:48 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
202 |
16486400 |
|
2000 |
87128893 |
Pety |
E |
July 17, 2020, 3:35 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
202 |
16998400 |
|
2000 |
87175976 |
misir |
E |
July 17, 2020, 7:25 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
202 |
17100800 |
|
2000 |
87179695 |
alleviatedRules |
E |
July 17, 2020, 8:33 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
202 |
17612800 |
|
2000 |
87178234 |
_Subrata |
E |
July 17, 2020, 8:04 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
202 |
18636800 |
|
2000 |
87126432 |
Marcythm |
E |
July 17, 2020, 3:31 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
109 |
12492800 |
|
2000 |
87197047 |
kal013 |
E |
July 18, 2020, 5:28 a.m. |
OK |
GNU C++17 |
TESTS |
30 |
109 |
14848000 |
|
2000 |
87189507 |
PassingandBest |
E |
July 18, 2020, 2:21 a.m. |
OK |
GNU C++17 |
TESTS |
30 |
171 |
11161600 |
|
2000 |
87187599 |
vjudge1 |
E |
July 18, 2020, 1:26 a.m. |
OK |
GNU C++17 |
TESTS |
30 |
171 |
15155200 |
|
2000 |
87188097 |
zzy187 |
E |
July 18, 2020, 1:41 a.m. |
OK |
GNU C++17 |
TESTS |
30 |
171 |
15155200 |
|
2000 |
87190651 |
ddh |
E |
July 18, 2020, 2:51 a.m. |
OK |
GNU C++17 |
TESTS |
30 |
187 |
12697600 |
|
2000 |
87140987 |
xwd456 |
E |
July 17, 2020, 3:59 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
187 |
31232000 |
|
2000 |
87155878 |
HWorld2005 |
E |
July 17, 2020, 4:37 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
187 |
44851200 |
|
2000 |
87190187 |
violet.evergarden |
E |
July 18, 2020, 2:39 a.m. |
OK |
GNU C++17 |
TESTS |
30 |
187 |
75059200 |
|
2000 |
87184318 |
GabMei |
E |
July 17, 2020, 10:48 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
202 |
12697600 |
|
2000 |
87191569 |
ConanYu |
E |
July 18, 2020, 3:15 a.m. |
OK |
GNU C++17 (64) |
TESTS |
30 |
170 |
13824000 |
|
2000 |
87168945 |
erray |
E |
July 17, 2020, 5:58 p.m. |
OK |
GNU C++17 (64) |
TESTS |
30 |
186 |
16076800 |
|
2000 |
87125284 |
Svlad_Cjelli |
E |
July 17, 2020, 3:29 p.m. |
OK |
GNU C++17 (64) |
TESTS |
30 |
186 |
16384000 |
|
2000 |
87195182 |
Hyado |
E |
July 18, 2020, 4:40 a.m. |
OK |
GNU C++17 (64) |
TESTS |
30 |
186 |
20377600 |
|
2000 |
87146441 |
Theofratus |
E |
July 17, 2020, 4:12 p.m. |
OK |
GNU C++17 (64) |
TESTS |
30 |
186 |
20684800 |
|
2000 |
87176471 |
wistful23 |
E |
July 17, 2020, 7:33 p.m. |
OK |
GNU C++17 (64) |
TESTS |
30 |
186 |
22323200 |
|
2000 |
87182951 |
raj1307 |
E |
July 17, 2020, 10 p.m. |
OK |
GNU C++17 (64) |
TESTS |
30 |
186 |
24576000 |
|
2000 |
87127884 |
Lucina |
E |
July 17, 2020, 3:33 p.m. |
OK |
GNU C++17 (64) |
TESTS |
30 |
186 |
27033600 |
|
2000 |
87182346 |
thedonutguy |
E |
July 17, 2020, 9:43 p.m. |
OK |
GNU C++17 (64) |
TESTS |
30 |
186 |
27238400 |
|
2000 |
87182912 |
ankushkhanna |
E |
July 17, 2020, 9:58 p.m. |
OK |
GNU C++17 (64) |
TESTS |
30 |
187 |
15462400 |
|
2000 |
87140281 |
meooow |
E |
July 17, 2020, 3:58 p.m. |
OK |
Go |
TESTS |
30 |
233 |
30310400 |
|
2000 |
87151506 |
Opencup |
E |
July 17, 2020, 4:25 p.m. |
OK |
Go |
TESTS |
30 |
358 |
46899200 |
|
2000 |
87140060 |
synapse |
E |
July 17, 2020, 3:57 p.m. |
OK |
Go |
TESTS |
30 |
436 |
30617600 |
|
2000 |
87192967 |
synapse |
E |
July 18, 2020, 3:47 a.m. |
OK |
Go |
TESTS |
30 |
452 |
25907200 |
|
2000 |
87194272 |
AQZZ |
E |
July 18, 2020, 4:18 a.m. |
OK |
Java 11 |
TESTS |
30 |
421 |
62464000 |
|
2000 |
87181349 |
AQZZ |
E |
July 17, 2020, 9:14 p.m. |
OK |
Java 11 |
TESTS |
30 |
451 |
62156800 |
|
2000 |
87198079 |
sam_code |
E |
July 18, 2020, 5:43 a.m. |
OK |
Java 11 |
TESTS |
30 |
530 |
62054400 |
|
2000 |
87186368 |
Tatsuyaaaa |
E |
July 18, 2020, 12:24 a.m. |
OK |
Java 11 |
TESTS |
30 |
560 |
53043200 |
|
2000 |
87195852 |
skittles1412 |
E |
July 18, 2020, 4:54 a.m. |
OK |
Java 11 |
TESTS |
30 |
561 |
58572800 |
|
2000 |
87163190 |
atishay127 |
E |
July 17, 2020, 5:03 p.m. |
OK |
Java 11 |
TESTS |
30 |
577 |
68915200 |
|
2000 |
87155846 |
half_blood000 |
E |
July 17, 2020, 4:37 p.m. |
OK |
Java 11 |
TESTS |
30 |
592 |
59392000 |
|
2000 |
87153286 |
big_boy_coder |
E |
July 17, 2020, 4:30 p.m. |
OK |
Java 11 |
TESTS |
30 |
607 |
64000000 |
|
2000 |
87151885 |
sf14t |
E |
July 17, 2020, 4:26 p.m. |
OK |
Java 11 |
TESTS |
30 |
608 |
82329600 |
|
2000 |
87167132 |
Mann_27__ |
E |
July 17, 2020, 5:38 p.m. |
OK |
Java 11 |
TESTS |
30 |
624 |
75980800 |
|
2000 |
87194517 |
AQZZ |
E |
July 18, 2020, 4:25 a.m. |
OK |
Java 8 |
TESTS |
30 |
389 |
59392000 |
|
2000 |
87180878 |
AQZZ |
E |
July 17, 2020, 9:01 p.m. |
OK |
Java 8 |
TESTS |
30 |
405 |
61132800 |
|
2000 |
87165019 |
hulk_man |
E |
July 17, 2020, 5:17 p.m. |
OK |
Java 8 |
TESTS |
30 |
405 |
61849600 |
|
2000 |
87139288 |
KharYusuf |
E |
July 17, 2020, 3:56 p.m. |
OK |
Java 8 |
TESTS |
30 |
436 |
67174400 |
|
2000 |
87155398 |
rishisharma__ |
E |
July 17, 2020, 4:36 p.m. |
OK |
Java 8 |
TESTS |
30 |
436 |
99635200 |
|
2000 |
87138179 |
gawsfbet |
E |
July 17, 2020, 3:53 p.m. |
OK |
Java 8 |
TESTS |
30 |
483 |
61235200 |
|
2000 |
87185018 |
lzhang |
E |
July 17, 2020, 11:13 p.m. |
OK |
Java 8 |
TESTS |
30 |
483 |
95334400 |
|
2000 |
87169120 |
gagan_6730 |
E |
July 17, 2020, 6 p.m. |
OK |
Java 8 |
TESTS |
30 |
498 |
61337600 |
|
2000 |
87134314 |
Whiplash99 |
E |
July 17, 2020, 3:45 p.m. |
OK |
Java 8 |
TESTS |
30 |
530 |
64204800 |
|
2000 |
87130153 |
Ahmed_Hosssam |
E |
July 17, 2020, 3:37 p.m. |
OK |
Java 8 |
TESTS |
30 |
545 |
102400000 |
|
2000 |
87124706 |
Hakiobo |
E |
July 17, 2020, 3:28 p.m. |
OK |
Kotlin |
TESTS |
30 |
561 |
83353600 |
|
2000 |
87129170 |
ekaerovets |
E |
July 17, 2020, 3:35 p.m. |
OK |
Kotlin |
TESTS |
30 |
655 |
89600000 |
|
2000 |
87160674 |
songsinger |
E |
July 17, 2020, 4:49 p.m. |
OK |
Kotlin |
TESTS |
30 |
1325 |
59084800 |
|
2000 |
87165240 |
songsinger |
E |
July 17, 2020, 5:19 p.m. |
OK |
Kotlin |
TESTS |
30 |
1341 |
59084800 |
|
2000 |
87140462 |
terry_u16 |
E |
July 17, 2020, 3:58 p.m. |
OK |
Mono C# |
TESTS |
30 |
592 |
36044800 |
|
2000 |
87146715 |
mban259 |
E |
July 17, 2020, 4:13 p.m. |
OK |
Mono C# |
TESTS |
30 |
686 |
49766400 |
|
2000 |
87141151 |
r57shell |
E |
July 17, 2020, 4 p.m. |
OK |
MS C++ |
TESTS |
30 |
187 |
12902400 |
|
2000 |
87151748 |
otarra |
E |
July 17, 2020, 4:26 p.m. |
OK |
MS C++ 2017 |
TESTS |
30 |
264 |
11161600 |
|
2000 |
87135406 |
kupriyanov |
E |
July 17, 2020, 3:47 p.m. |
OK |
MS C++ 2017 |
TESTS |
30 |
686 |
15667200 |
|
2000 |
87163837 |
deuslovelt |
E |
July 17, 2020, 5:07 p.m. |
OK |
MS C++ 2017 |
TESTS |
30 |
717 |
14438400 |
|
2000 |
87158820 |
Wonsei |
E |
July 17, 2020, 4:45 p.m. |
OK |
MS C++ 2017 |
TESTS |
30 |
732 |
13414400 |
|
2000 |
87136988 |
Gravekper |
E |
July 17, 2020, 3:51 p.m. |
OK |
MS C++ 2017 |
TESTS |
30 |
733 |
19148800 |
|
2000 |
87158535 |
Wonsei |
E |
July 17, 2020, 4:45 p.m. |
OK |
MS C++ 2017 |
TESTS |
30 |
748 |
17612800 |
|
2000 |
87164809 |
getN1ght |
E |
July 17, 2020, 5:16 p.m. |
OK |
MS C++ 2017 |
TESTS |
30 |
998 |
19456000 |
|
2000 |
87156032 |
llorvje |
E |
July 17, 2020, 4:38 p.m. |
OK |
MS C++ 2017 |
TESTS |
30 |
1372 |
18022400 |
|
2000 |
87183878 |
Targas |
E |
July 17, 2020, 10:31 p.m. |
OK |
MS C++ 2017 |
TESTS |
30 |
1434 |
34713600 |
|
2000 |
87182651 |
anoubhav |
E |
July 17, 2020, 9:51 p.m. |
OK |
PyPy 3 |
TESTS |
30 |
701 |
78336000 |
|
2000 |
87184914 |
Satwik_Tiwari |
E |
July 17, 2020, 11:08 p.m. |
OK |
PyPy 3 |
TESTS |
30 |
748 |
68198400 |
|
2000 |
87165770 |
throwawayatcoder |
E |
July 17, 2020, 5:24 p.m. |
OK |
PyPy 3 |
TESTS |
30 |
889 |
110592000 |
|
2000 |
87167564 |
yuusanlondon |
E |
July 17, 2020, 5:42 p.m. |
OK |
PyPy 3 |
TESTS |
30 |
951 |
71884800 |
|
2000 |
87136556 |
aberent |
E |
July 17, 2020, 3:50 p.m. |
OK |
PyPy 3 |
TESTS |
30 |
1045 |
87859200 |
|
2000 |
87165660 |
throwawayatcoder |
E |
July 17, 2020, 5:23 p.m. |
OK |
PyPy 3 |
TESTS |
30 |
1091 |
165785600 |
|
2000 |
87198180 |
wishcode |
E |
July 18, 2020, 5:44 a.m. |
OK |
PyPy 3 |
TESTS |
30 |
1107 |
73318400 |
|
2000 |
87197510 |
enraged |
E |
July 18, 2020, 5:35 a.m. |
OK |
PyPy 3 |
TESTS |
30 |
1123 |
76185600 |
|
2000 |
87175343 |
__eRRor__ |
E |
July 17, 2020, 7:16 p.m. |
OK |
PyPy 3 |
TESTS |
30 |
1169 |
90624000 |
|
2000 |
87167928 |
Naman_Tyagi |
E |
July 17, 2020, 5:46 p.m. |
OK |
PyPy 3 |
TESTS |
30 |
1185 |
66867200 |
|
2000 |
87132527 |
stnkien |
E |
July 17, 2020, 3:42 p.m. |
OK |
Python 3 |
TESTS |
30 |
1387 |
33382400 |
|
2000 |
87169588 |
dominator1234 |
E |
July 17, 2020, 6:05 p.m. |
OK |
Python 3 |
TESTS |
30 |
1652 |
37785600 |
|
2000 |
87156585 |
codingbug4sure |
E |
July 17, 2020, 4:39 p.m. |
OK |
Python 3 |
TESTS |
30 |
1684 |
53248000 |
|
2000 |
87166452 |
sh1194 |
E |
July 17, 2020, 5:31 p.m. |
OK |
Python 3 |
TESTS |
30 |
1716 |
53248000 |
|
2000 |
87163711 |
amanoswal22 |
E |
July 17, 2020, 5:07 p.m. |
OK |
Python 3 |
TESTS |
30 |
2246 |
51404800 |
|
2000 |
87192925 |
sansen |
E |
July 18, 2020, 3:46 a.m. |
OK |
Rust |
TESTS |
30 |
109 |
19148800 |
|
2000 |
87130994 |
yoshrc |
E |
July 17, 2020, 3:39 p.m. |
OK |
Rust |
TESTS |
30 |
1809 |
13926400 |
|
2000 |
87150518 |
komorin95 |
E |
July 17, 2020, 4:23 p.m. |
OK |
Rust |
TESTS |
30 |
1965 |
25497600 |
|
2000 |
remove filters
Back to search problems