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 |
---|---|---|---|---|---|---|
1676 | Codeforces Round 790 (Div. 4) | FINISHED | False | 7200 | 84986063 | May 10, 2022, 2:45 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 16628 ) | G | White-Black Balanced Subtrees | PROGRAMMING | dfs and similar dp graphs trees |
B'You are given a rooted tree consisting of n vertices numbered from 1 to n . The root is vertex 1 . There is also a string s denoting the color of each vertex: if s_i = texttt{B} , then vertex i is black, and if s_i = texttt{W} , then vertex i is white. A subtree of the tree is called balanced if the number of white vertices equals the number of black vertices. Count the number of balanced subtrees. A tree is a connected undirected graph without cycles. A rooted tree is a tree with a selected vertex, which is called the root. In this problem, all trees have root 1 . The tree is specified by an array of parents a_2, ... , a_n containing n-1 numbers: a_i is the parent of the vertex with the number i for all i = 2, ... , n . The parent of a vertex u is a vertex that is the next vertex on a simple path from u to the root. The subtree of a vertex u is the set of all vertices that pass through u on a simple path to the root. For example, in the picture below, 7 is in the subtree of 3 because the simple path 7 to 5 to 3 to 1 passes through 3 . Note that a vertex is included in its subtree, and the subtree of the root is the entire tree. The first line of input contains an integer t ( 1 <= t <= 10^4 ) -- the number of test cases. The first line of each test case contains an integer n ( 2 <= n <= 4000 ) -- the number of vertices in the tree. The second line of each test case contains n-1 integers a_2, ... , a_n ( 1 <= a_i < i ) -- the parents of the vertices 2, ... , n . The third line of each test case contains a string s of length n consisting of the characters texttt{B} and texttt{W} -- the coloring of the tree. It is guaranteed that the sum of the values n over all test cases does not exceed 2 cdot 10^5 . For each test case, output a s'... |
Codeforces Round #790 (Div. 4) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
156872050 | sasung | G | May 11, 2022, 10:35 p.m. | OK | C# 10 | TESTS | 18 | 171 | 8089600 | ||
156863706 | Denor | G | May 11, 2022, 7:18 p.m. | OK | Delphi | TESTS | 18 | 31 | 102400 | ||
156834433 | ruban | G | May 11, 2022, 1:12 p.m. | OK | FPC | TESTS | 18 | 77 | 162713600 | ||
156789381 | beep_boop | G | May 11, 2022, 7:01 a.m. | OK | GNU C++14 | TESTS | 18 | 31 | 512000 | ||
156876866 | 100476241 | G | May 12, 2022, 1:49 a.m. | OK | GNU C++14 | TESTS | 18 | 46 | 0 | ||
156851962 | Yewandou | G | May 11, 2022, 4:35 p.m. | OK | GNU C++14 | TESTS | 18 | 46 | 204800 | ||
156850084 | chenjs | G | May 11, 2022, 4:12 p.m. | OK | GNU C++14 | TESTS | 18 | 46 | 204800 | ||
156879957 | MohamedMamdouh19 | G | May 12, 2022, 3:16 a.m. | OK | GNU C++14 | TESTS | 18 | 46 | 409600 | ||
156886618 | omi_farhan75 | G | May 12, 2022, 5:36 a.m. | OK | GNU C++14 | TESTS | 18 | 46 | 512000 | ||
156885774 | Mr_Frodo | G | May 12, 2022, 5:20 a.m. | OK | GNU C++14 | TESTS | 18 | 46 | 512000 | ||
156880018 | shenfugui | G | May 12, 2022, 3:17 a.m. | OK | GNU C++14 | TESTS | 18 | 46 | 512000 | ||
156867991 | AnshumanSingh11 | G | May 11, 2022, 8:38 p.m. | OK | GNU C++14 | TESTS | 18 | 46 | 512000 | ||
156845384 | luogu_bot5 | G | May 11, 2022, 3:15 p.m. | OK | GNU C++14 | TESTS | 18 | 46 | 512000 | ||
156834724 | Pcjmy | G | May 11, 2022, 1:15 p.m. | OK | GNU C++17 | TESTS | 18 | 31 | 512000 | ||
156821357 | Dub | G | May 11, 2022, 10:59 a.m. | OK | GNU C++17 | TESTS | 18 | 31 | 512000 | ||
156860158 | BadHero | G | May 11, 2022, 6:26 p.m. | OK | GNU C++17 | TESTS | 18 | 31 | 614400 | ||
156871425 | Pulgster | G | May 11, 2022, 10:10 p.m. | OK | GNU C++17 | TESTS | 18 | 31 | 2252800 | ||
156877152 | Liam_Evander | G | May 12, 2022, 1:58 a.m. | OK | GNU C++17 | TESTS | 18 | 31 | 4505600 | ||
156849070 | triathlon | G | May 11, 2022, 4 p.m. | OK | GNU C++17 | TESTS | 18 | 46 | 0 | ||
156800533 | lfy0 | G | May 11, 2022, 9:18 a.m. | OK | GNU C++17 | TESTS | 18 | 46 | 204800 | ||
156790262 | Ruins | G | May 11, 2022, 7:13 a.m. | OK | GNU C++17 | TESTS | 18 | 46 | 204800 | ||
156867880 | AppleJack2001 | G | May 11, 2022, 8:36 p.m. | OK | GNU C++17 | TESTS | 18 | 46 | 307200 | ||
156854484 | Belayed | G | May 11, 2022, 5:10 p.m. | OK | GNU C++17 | TESTS | 18 | 46 | 307200 | ||
156867838 | HanaaAhmed | G | May 11, 2022, 8:35 p.m. | OK | GNU C++17 (64) | TESTS | 18 | 31 | 409600 | ||
156842988 | ferrari430 | G | May 11, 2022, 2:44 p.m. | OK | GNU C++17 (64) | TESTS | 18 | 31 | 614400 | ||
156792059 | suryam35 | G | May 11, 2022, 7:35 a.m. | OK | GNU C++17 (64) | TESTS | 18 | 31 | 614400 | ||
156791767 | _Pioneer | G | May 11, 2022, 7:32 a.m. | OK | GNU C++17 (64) | TESTS | 18 | 31 | 614400 | ||
156791751 | _Pioneer | G | May 11, 2022, 7:32 a.m. | OK | GNU C++17 (64) | TESTS | 18 | 31 | 614400 | ||
156793672 | PurpleCJ | G | May 11, 2022, 7:55 a.m. | OK | GNU C++17 (64) | TESTS | 18 | 31 | 716800 | ||
156788152 | jitu_falcon15 | G | May 11, 2022, 6:47 a.m. | OK | GNU C++17 (64) | TESTS | 18 | 31 | 1024000 | ||
156874657 | Meteor_Z | G | May 12, 2022, 12:28 a.m. | OK | GNU C++17 (64) | TESTS | 18 | 31 | 1228800 | ||
156837123 | Meteor_Z | G | May 11, 2022, 1:40 p.m. | OK | GNU C++17 (64) | TESTS | 18 | 31 | 1228800 | ||
156864704 | HP_BenLadeN | G | May 11, 2022, 7:36 p.m. | OK | GNU C++17 (64) | TESTS | 18 | 31 | 2048000 | ||
156886091 | karmanye1234 | G | May 12, 2022, 5:26 a.m. | OK | GNU C++20 (64) | TESTS | 18 | 15 | 102400 | ||
156881354 | mcj201314 | G | May 12, 2022, 3:49 a.m. | OK | GNU C++20 (64) | TESTS | 18 | 31 | 102400 | ||
156872729 | Yousry_Essam | G | May 11, 2022, 11 p.m. | OK | GNU C++20 (64) | TESTS | 18 | 31 | 102400 | ||
156842977 | 1.618033 | G | May 11, 2022, 2:44 p.m. | OK | GNU C++20 (64) | TESTS | 18 | 31 | 102400 | ||
156837329 | bin_s | G | May 11, 2022, 1:42 p.m. | OK | GNU C++20 (64) | TESTS | 18 | 31 | 102400 | ||
156824926 | pankaj_m05 | G | May 11, 2022, 11:38 a.m. | OK | GNU C++20 (64) | TESTS | 18 | 31 | 102400 | ||
156822372 | crap_the_coder | G | May 11, 2022, 11:11 a.m. | OK | GNU C++20 (64) | TESTS | 18 | 31 | 102400 | ||
156816472 | Maango16 | G | May 11, 2022, 10:02 a.m. | OK | GNU C++20 (64) | TESTS | 18 | 31 | 102400 | ||
156800661 | lfy2 | G | May 11, 2022, 9:19 a.m. | OK | GNU C++20 (64) | TESTS | 18 | 31 | 102400 | ||
156855352 | whateverittakes_465 | G | May 11, 2022, 5:23 p.m. | OK | GNU C++20 (64) | TESTS | 18 | 31 | 204800 | ||
156865667 | dhruvil_01 | G | May 11, 2022, 7:53 p.m. | OK | Java 11 | TESTS | 18 | 218 | 0 | ||
156800603 | Aaryendra | G | May 11, 2022, 9:19 a.m. | OK | Java 11 | TESTS | 18 | 218 | 0 | ||
156855903 | amritagg | G | May 11, 2022, 5:31 p.m. | OK | Java 11 | TESTS | 18 | 218 | 2048000 | ||
156867256 | eshan18.09 | G | May 11, 2022, 8:23 p.m. | OK | Java 11 | TESTS | 18 | 264 | 0 | ||
156848958 | HelloWorld03 | G | May 11, 2022, 3:58 p.m. | OK | Java 11 | TESTS | 18 | 280 | 0 | ||
156795448 | yash13203 | G | May 11, 2022, 8:18 a.m. | OK | Java 11 | TESTS | 18 | 280 | 0 | ||
156800921 | amitmandal | G | May 11, 2022, 9:22 a.m. | OK | Java 11 | TESTS | 18 | 295 | 2252800 | ||
156844946 | anmol.mact | G | May 11, 2022, 3:10 p.m. | OK | Java 11 | TESTS | 18 | 296 | 1638400 | ||
156875740 | jsheng555 | G | May 12, 2022, 1:08 a.m. | OK | Java 11 | TESTS | 18 | 499 | 409600 | ||
156876622 | bully_maguire | G | May 12, 2022, 1:40 a.m. | OK | Java 11 | TESTS | 18 | 514 | 307200 | ||
156885051 | govindrajput | G | May 12, 2022, 5:07 a.m. | OK | Java 8 | TESTS | 18 | 124 | 0 | ||
156847814 | sharpen | G | May 11, 2022, 3:45 p.m. | OK | Java 8 | TESTS | 18 | 139 | 0 | ||
156804648 | ttolkku | G | May 11, 2022, 9:25 a.m. | OK | Java 8 | TESTS | 18 | 139 | 0 | ||
156855099 | srijanchakraborty | G | May 11, 2022, 5:19 p.m. | OK | Java 8 | TESTS | 18 | 140 | 0 | ||
156818945 | pribic | G | May 11, 2022, 10:30 a.m. | OK | Java 8 | TESTS | 18 | 202 | 0 | ||
156800004 | ardekarsanket | G | May 11, 2022, 9:12 a.m. | OK | Java 8 | TESTS | 18 | 202 | 0 | ||
156844534 | crFlowerz | G | May 11, 2022, 3:04 p.m. | OK | Java 8 | TESTS | 18 | 234 | 0 | ||
156878682 | tanishq044 | G | May 12, 2022, 2:41 a.m. | OK | Java 8 | TESTS | 18 | 374 | 0 | ||
156878547 | tanishq044 | G | May 12, 2022, 2:38 a.m. | OK | Java 8 | TESTS | 18 | 374 | 0 | ||
156876233 | gblake31 | G | May 12, 2022, 1:26 a.m. | OK | Java 8 | TESTS | 18 | 389 | 0 | ||
156832592 | Superlau | G | May 11, 2022, 12:54 p.m. | OK | MS C++ 2017 | TESTS | 18 | 62 | 204800 | ||
156792529 | jianguolinyun | G | May 11, 2022, 7:41 a.m. | OK | MS C++ 2017 | TESTS | 18 | 124 | 512000 | ||
156867527 | Still_Theory | G | May 11, 2022, 8:29 p.m. | OK | MS C++ 2017 | TESTS | 18 | 156 | 307200 | ||
156793719 | A_Pier | G | May 11, 2022, 7:56 a.m. | OK | MS C++ 2017 | TESTS | 18 | 170 | 307200 | ||
156845653 | dimas1488 | G | May 11, 2022, 3:18 p.m. | OK | MS C++ 2017 | TESTS | 18 | 577 | 204800 | ||
156815008 | XYShaoKang | G | May 11, 2022, 9:44 a.m. | OK | Node.js | TESTS | 18 | 218 | 11878400 | ||
156830850 | hibye1217 | G | May 11, 2022, 12:37 p.m. | OK | PyPy 3 | TESTS | 18 | 295 | 11059200 | ||
156880126 | ranger2001 | G | May 12, 2022, 3:20 a.m. | OK | PyPy 3 | TESTS | 18 | 498 | 9830400 | ||
156849424 | Marco_Lau | G | May 11, 2022, 4:04 p.m. | OK | PyPy 3-64 | TESTS | 18 | 187 | 11366400 | ||
156854964 | notTehlka | G | May 11, 2022, 5:17 p.m. | OK | PyPy 3-64 | TESTS | 18 | 187 | 13107200 | ||
156814674 | asdsasd | G | May 11, 2022, 9:40 a.m. | OK | PyPy 3-64 | TESTS | 18 | 217 | 11161600 | ||
156838695 | kojihashimoto | G | May 11, 2022, 1:57 p.m. | OK | PyPy 3-64 | TESTS | 18 | 264 | 10752000 | ||
156799328 | oadey89 | G | May 11, 2022, 9:03 a.m. | OK | PyPy 3-64 | TESTS | 18 | 295 | 23244800 | ||
156823333 | jainmilind | G | May 11, 2022, 11:21 a.m. | OK | PyPy 3-64 | TESTS | 18 | 343 | 15974400 | ||
156875203 | SoWhat0309 | G | May 12, 2022, 12:48 a.m. | OK | PyPy 3-64 | TESTS | 18 | 420 | 159744000 | ||
156834642 | niumeng | G | May 11, 2022, 1:14 p.m. | OK | PyPy 3-64 | TESTS | 18 | 467 | 10547200 | ||
156834299 | niumeng | G | May 11, 2022, 1:11 p.m. | OK | PyPy 3-64 | TESTS | 18 | 483 | 10649600 | ||
156867859 | Stahloh | G | May 11, 2022, 8:35 p.m. | OK | PyPy 3-64 | TESTS | 18 | 498 | 12390400 | ||
156872480 | crapcode | G | May 11, 2022, 10:50 p.m. | OK | Python 3 | TESTS | 18 | 311 | 6860800 | ||
156886641 | jloai009 | G | May 12, 2022, 5:36 a.m. | OK | Python 3 | TESTS | 18 | 327 | 3891200 | ||
156886520 | jloai009 | G | May 12, 2022, 5:34 a.m. | OK | Python 3 | TESTS | 18 | 327 | 4096000 | ||
156886612 | jloai009 | G | May 12, 2022, 5:36 a.m. | OK | Python 3 | TESTS | 18 | 342 | 3891200 | ||
156886010 | jloai009 | G | May 12, 2022, 5:25 a.m. | OK | Python 3 | TESTS | 18 | 342 | 3993600 | ||
156867216 | mishgun | G | May 11, 2022, 8:22 p.m. | OK | Python 3 | TESTS | 18 | 358 | 3379200 | ||
156886885 | jloai009 | G | May 12, 2022, 5:41 a.m. | OK | Python 3 | TESTS | 18 | 358 | 3891200 | ||
156884285 | jloai009 | G | May 12, 2022, 4:52 a.m. | OK | Python 3 | TESTS | 18 | 358 | 3891200 | ||
156885230 | jloai009 | G | May 12, 2022, 5:10 a.m. | OK | Python 3 | TESTS | 18 | 373 | 3891200 | ||
156818035 | dawitys010 | G | May 11, 2022, 10:20 a.m. | OK | Python 3 | TESTS | 18 | 373 | 139571200 |
Back to search problems