Codeforces Round 1086 (Div. 2)

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.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
2208 Codeforces Round 1086 (Div. 2) FINISHED False 7200 3425085 March 14, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 1776 ) D2 Tree Orientation (Hard Version) PROGRAMMING data structures dfs and similar dsu graphs greedy matrices sortings trees

This is the hard version of the problem. The difference between the versions is that in this version, the constraint on (n) is higher. You can hack only if you solved all versions of this problem. You once had an undirected tree with (n) nodes. To make the tree look more interesting, you decided to assign an arbitary direction to each of the (n-1) edges. As time goes by, you forgot the structure of your tree. However, you found a note which recorded after the direction of the edges have been assigned, whether (u) can reach (v)(^{\text{∗}}) for all ordered pairs of ((u,v)) which satisfies (1\le u,v\le n). You want to find out the structure of the tree and the direction of the edges from the information given by the note. Determine if there is possible solution and construct one. If there are multiple solutions, you only need to find one of them. (^{\text{∗}})For a directed graph, we say that (x) can reach (y) if and only if there exists a sequence of nodes (u_1,u_2,\ldots,u_k) such that (u_1=x,u_k=y) and for all (i) from (2) to (k), the directed edge (u_{i-1}\rightarrow u_i) exists. In particular, a node can always reach itself. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test cases contain an integer (n) ((2\le n\le 8000)) denoting the number of nodes your tree have. The following (n) lines contain a string (s_i). (s_i) is of length (n) and consists only of (0) and (1). The (j)-th character of (s_i) is (1) if and only if (i) can reach (j) after the edges are directed. It is guaranteed that the sum of (n^2) over all test cases does not exceed (8000^2). For each testcase, output (Yes) if a solution exists, otherwise print (No). If the answer is (Yes),

Tutorials

Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
366705276 probablyronit D2 March 14, 2026, 4:24 p.m. OK C++17 (GCC 7-32) TESTS 40 500 16281600
366728859 ShadowSlayer1 D2 March 14, 2026, 7:42 p.m. OK C++17 (GCC 7-32) TESTS 40 515 16281600
366715173 _annhien_ruby22 D2 March 14, 2026, 5:33 p.m. OK C++17 (GCC 7-32) TESTS 40 531 24473600
366748260 xuangou D2 March 15, 2026, 1:41 a.m. OK C++17 (GCC 7-32) TESTS 40 546 8396800
366731292 AII_Might D2 March 14, 2026, 8:11 p.m. OK C++17 (GCC 7-32) TESTS 40 562 4608000
366701559 pritamde090920 D2 March 14, 2026, 4:16 p.m. OK C++17 (GCC 7-32) TESTS 40 656 5120000
366756380 thnhann D2 March 15, 2026, 4:25 a.m. OK C++17 (GCC 7-32) TESTS 40 656 208896000
366740838 manpantheo D2 March 14, 2026, 10:42 p.m. OK C++17 (GCC 7-32) TESTS 40 671 102297600
366709232 ELiu D2 March 14, 2026, 4:33 p.m. OK C++17 (GCC 7-32) TESTS 40 671 110592000
366701556 mozkomor05 D2 March 14, 2026, 4:16 p.m. OK C++17 (GCC 7-32) TESTS 40 703 8089600
366761470 e2.71842069 D2 March 15, 2026, 5:35 a.m. OK C++20 (GCC 13-64) TESTS 40 375 14438400
366758606 scar.face D2 March 15, 2026, 5 a.m. OK C++20 (GCC 13-64) TESTS 40 453 16179200
366751505 Sungl D2 March 15, 2026, 2:53 a.m. OK C++20 (GCC 13-64) TESTS 40 515 16281600
366745669 AILevel D2 March 15, 2026, 12:32 a.m. OK C++20 (GCC 13-64) TESTS 40 531 12800000
366703793 Phoenix_12 D2 March 14, 2026, 4:21 p.m. OK C++20 (GCC 13-64) TESTS 40 531 16281600
366701279 Talent_Camellia D2 March 14, 2026, 4:15 p.m. OK C++20 (GCC 13-64) TESTS 40 546 90624000
366741941 chandler1837 D2 March 14, 2026, 11:06 p.m. OK C++20 (GCC 13-64) TESTS 40 562 95539200
366718379 Yagnik_Dhameliya D2 March 14, 2026, 5:58 p.m. OK C++20 (GCC 13-64) TESTS 40 578 621977600
366722353 nottpro D2 March 14, 2026, 6:32 p.m. OK C++20 (GCC 13-64) TESTS 40 593 24268800
366751609 Anand_Bharti D2 March 15, 2026, 2:55 a.m. OK C++20 (GCC 13-64) TESTS 40 593 615014400
366745177 shiinamashiro_ D2 March 15, 2026, 12:18 a.m. OK C++23 (GCC 14-64, msys2) TESTS 40 328 8294400
366746653 shiinamashiro_ D2 March 15, 2026, 1 a.m. OK C++23 (GCC 14-64, msys2) TESTS 40 359 8294400
366732898 Electro_Valkyrie D2 March 14, 2026, 8:31 p.m. OK C++23 (GCC 14-64, msys2) TESTS 40 359 16384000
366745487 shiinamashiro_ D2 March 15, 2026, 12:27 a.m. OK C++23 (GCC 14-64, msys2) TESTS 40 375 8294400
366745370 shiinamashiro_ D2 March 15, 2026, 12:23 a.m. OK C++23 (GCC 14-64, msys2) TESTS 40 375 8294400
366745121 shiinamashiro_ D2 March 15, 2026, 12:16 a.m. OK C++23 (GCC 14-64, msys2) TESTS 40 375 8294400
366745279 shiinamashiro_ D2 March 15, 2026, 12:21 a.m. OK C++23 (GCC 14-64, msys2) TESTS 40 390 8294400
366716059 vedantkohad D2 March 14, 2026, 5:40 p.m. OK C++23 (GCC 14-64, msys2) TESTS 40 421 16281600
366732964 yoki D2 March 14, 2026, 8:32 p.m. OK C++23 (GCC 14-64, msys2) TESTS 40 437 5222400
366727779 salatunia D2 March 14, 2026, 7:30 p.m. OK C++23 (GCC 14-64, msys2) TESTS 40 437 5222400
366750115 MBBN D2 March 15, 2026, 2:21 a.m. OK Java 21 TESTS 40 828 7782400
366726460 shubhansh_gupta D2 March 14, 2026, 7:15 p.m. OK Java 21 TESTS 40 859 7168000
366704999 manmohan0singh0 D2 March 14, 2026, 4:24 p.m. OK Java 21 TESTS 40 1062 9625600
366707413 Sarthak1712 D2 March 14, 2026, 4:29 p.m. OK Java 21 TESTS 40 1312 20070400
366746196 kartik__sethi D2 March 15, 2026, 12:47 a.m. OK Java 21 TESTS 40 1437 18022400
366726826 rachit.gupta D2 March 14, 2026, 7:19 p.m. OK Java 21 TESTS 40 1718 79974400
366705391 Bicky_verma077 D2 March 14, 2026, 4:25 p.m. OK Java 21 TESTS 40 1718 79974400
366704118 pieande D2 March 14, 2026, 4:22 p.m. OK Java 21 TESTS 40 1859 80691200
366700827 shortestpi D2 March 14, 2026, 4:14 p.m. OK Java 21 TESTS 40 2093 124620800
366751972 buitS D2 March 15, 2026, 3:03 a.m. OK Java 21 TESTS 40 2171 7372800

remove filters

Back to search problems