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 |
|---|---|---|---|---|---|---|
| 786 | Codeforces Round 406 (Div. 1) | FINISHED | False | 7200 | 286124123 | March 23, 2017, 3:05 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 168 ) | D | Rap God | PROGRAMMING | data structures dfs and similar hashing strings trees | 3300 |
Rick is in love with Unity. But Mr. Meeseeks also love Unity, so Rick and Mr. Meeseeks are "love rivals". Unity loves rap, so it decided that they have to compete in a rap game (battle) in order to choose the best. Rick is too nerds, so instead he's gonna make his verse with running his original algorithm on lyrics "Rap God" song. His algorithm is a little bit complicated. He's made a tree with n vertices numbered from 1 to n and there's a lowercase english letter written on each edge. He denotes str ( a , b ) to be the string made by writing characters on edges on the shortest path from a to b one by one (a string of length equal to distance of a to b ). Note that str ( a , b ) is reverse of str ( b , a ) and str ( a , a ) is empty. In order to make the best verse he can, he needs to answer some queries, but he's not a computer scientist and is not able to answer those queries, so he asked you to help him. Each query is characterized by two vertices x and y ( x ≠ y ). Answer to this query is the number of vertices like z such that z ≠ x , z ≠ y and str ( x , y ) is lexicographically larger than str ( x , z ) . String x = x 1 x 2 ... x | x | is lexicographically larger than string y = y 1 y 2 ... y | y | , if either | x | > | y | and x 1 = y 1 , x 2 = y 2 , ..., x | y | = y | y | , or exists such number r ( r < | x |, r < | y |) , that x 1 = y 1 , x 2 = y 2 , ..., x r = y r and x r + 1 > y r + 1 . Characters are compared like their ASCII codes (or alphabetic order). Help Rick get the girl (or whatever gender Unity has). The first line of input contain two integers n and q ( 2 ≤ n ≤ 20000 , 1 ≤ q ≤ 20000 ) — number of vertices in tree and number of queries respectively. The next n - 1 lines contain the edges. Each line contains two integers v and u (endpoints of the edge) followed by an English lowercase letter c ( 1 ≤ v , u ≤ n , v ≠ u ). The next q line contain the queries. Each line contains two integers x and y ( 1 ≤ x , y ≤ n , x ≠ y ). Print the answe |
| Codeforces Round #406 Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 27730095 | AkaneSasu | D | June 12, 2017, 3:18 a.m. | OK | GNU C++ | TESTS | 55 | 1575 | 23347200 | 3300 | |
| 26253001 | tlzmybm | D | April 10, 2017, 12:35 p.m. | OK | GNU C++ | TESTS | 55 | 2293 | 13107200 | 3300 | |
| 27947676 | Out_of_Cage | D | June 21, 2017, 2:17 p.m. | OK | GNU C++ | TESTS | 55 | 2901 | 23961600 | 3300 | |
| 28322583 | yml | D | July 6, 2017, 9:38 a.m. | OK | GNU C++ | TESTS | 55 | 4445 | 8396800 | 3300 | |
| 42299282 | Scut82 | D | Aug. 31, 2018, 6:27 a.m. | OK | GNU C++ | TESTS | 55 | 6240 | 3584000 | 3300 | |
| 25820897 | krijgertje | D | March 26, 2017, 1:55 p.m. | OK | GNU C++11 | TESTS | 55 | 654 | 34713600 | 3300 | |
| 69713779 | gongsuidashen | D | Jan. 29, 2020, 8:11 a.m. | OK | GNU C++11 | TESTS | 55 | 1247 | 23347200 | 3300 | |
| 54064409 | cppascalinux | D | May 13, 2019, 12:44 p.m. | OK | GNU C++11 | TESTS | 55 | 1840 | 120217600 | 3300 | |
| 25872283 | Hobbit404 | D | March 28, 2017, 11:48 a.m. | OK | GNU C++11 | TESTS | 55 | 2558 | 4300800 | 3300 | |
| 25835352 | nhphuongltv | D | March 27, 2017, 9:47 a.m. | OK | GNU C++11 | TESTS | 55 | 3057 | 4198400 | 3300 | |
| 31707824 | hawkomg | D | Oct. 25, 2017, 11:58 a.m. | OK | GNU C++11 | TESTS | 55 | 3541 | 18944000 | 3300 | |
| 45225607 | JRCruz | D | Nov. 3, 2018, 2:59 a.m. | OK | GNU C++11 | TESTS | 55 | 3806 | 2867200 | 3300 | |
| 45225550 | ArcadioN | D | Nov. 3, 2018, 2:56 a.m. | OK | GNU C++11 | TESTS | 55 | 3806 | 2867200 | 3300 | |
| 39402653 | vjudge2 | D | June 19, 2018, 7:58 a.m. | OK | GNU C++11 | TESTS | 55 | 3806 | 30822400 | 3300 | |
| 39406594 | ohweonfire | D | June 19, 2018, 10:12 a.m. | OK | GNU C++11 | TESTS | 55 | 3868 | 30924800 | 3300 | |
| 26351664 | PEDY4000 | D | April 14, 2017, 7:04 a.m. | OK | GNU C++14 | TESTS | 55 | 249 | 23859200 | 3300 | |
| 26223180 | Los_Angelos_Laycurse | D | April 8, 2017, 4:31 p.m. | OK | GNU C++14 | TESTS | 55 | 265 | 23859200 | 3300 | |
| 26219711 | Los_Angelos_Laycurse | D | April 8, 2017, 1:14 p.m. | OK | GNU C++14 | TESTS | 55 | 265 | 23859200 | 3300 | |
| 26214476 | Los_Angelos_Laycurse | D | April 8, 2017, 8:58 a.m. | OK | GNU C++14 | TESTS | 55 | 265 | 117862400 | 3300 | |
| 40981996 | ReaLNero1 | D | July 30, 2018, 6:13 p.m. | OK | GNU C++14 | TESTS | 55 | 280 | 115916800 | 3300 | |
| 41311843 | killing_my_self | D | Aug. 7, 2018, 4:39 p.m. | OK | GNU C++14 | TESTS | 55 | 295 | 115814400 | 3300 | |
| 26219679 | Los_Angelos_Laycurse | D | April 8, 2017, 1:13 p.m. | OK | GNU C++14 | TESTS | 55 | 311 | 23859200 | 3300 | |
| 41206119 | -_-Hacker-_- | D | Aug. 4, 2018, 7:56 a.m. | OK | GNU C++14 | TESTS | 55 | 530 | 32460800 | 3300 | |
| 29083952 | Ken_He | D | Aug. 1, 2017, 1:16 a.m. | OK | GNU C++14 | TESTS | 55 | 1029 | 42496000 | 3300 | |
| 29084113 | Ken_He | D | Aug. 1, 2017, 1:26 a.m. | OK | GNU C++14 | TESTS | 55 | 1060 | 10649600 | 3300 | |
| 46270237 | kczno1 | D | Nov. 27, 2018, 7:31 a.m. | OK | GNU C++17 | TESTS | 55 | 4273 | 2969600 | 3300 | |
| 26214395 | Los_Angelos_Laycurse | D | April 8, 2017, 8:55 a.m. | OK | MS C++ | TESTS | 55 | 327 | 119603200 | 3300 | |
| 26153907 | Los_Angelos_Laycurse | D | April 5, 2017, 5:13 p.m. | OK | MS C++ | TESTS | 55 | 2589 | 4096000 | 3300 |
Back to search problems