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 |
|---|---|---|---|---|---|---|
| 715 | Codeforces Round 372 (Div. 1) | FINISHED | False | 7200 | 302285723 | Sept. 17, 2016, 1:45 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 2573 ) | C | Digit Tree | PROGRAMMING | dfs and similar divide and conquer dsu trees | 2800 |
ZS the Coder has a large tree. It can be represented as an undirected connected graph of n vertices numbered from 0 to n - 1 and n - 1 edges between them. There is a single nonzero digit written on each edge. One day, ZS the Coder was bored and decided to investigate some properties of the tree. He chose a positive integer M , which is coprime to 10 , i.e. . ZS consider an ordered pair of distinct vertices ( u , v ) interesting when if he would follow the shortest path from vertex u to vertex v and write down all the digits he encounters on his path in the same order, he will get a decimal representaion of an integer divisible by M . Formally, ZS consider an ordered pair of distinct vertices ( u , v ) interesting if the following states true: Let a 1 = u , a 2 , ..., a k = v be the sequence of vertices on the shortest path from u to v in the order of encountering them; Let d i ( 1 ≤ i < k ) be the digit written on the edge between vertices a i and a i + 1 ; The integer is divisible by M . Help ZS the Coder find the number of interesting pairs! The first line of the input contains two integers, n and M ( 2 ≤ n ≤ 100 000 , 1 ≤ M ≤ 10 9 , ) — the number of vertices and the number ZS has chosen respectively. The next n - 1 lines contain three integers each. i -th of them contains u i , v i and w i , denoting an edge between vertices u i and v i with digit w i written on it ( 0 ≤ u i , v i < n , 1 ≤ w i ≤ 9 ). Print a single integer — the number of interesting (by ZS the Coder's consideration) pairs. In the first sample case, the interesting pairs are (0, 4), (1, 2), (1, 5), (3, 2), (2, 5), (5, 2), (3, 5) . The numbers that are formed by these pairs are 14, 21, 217, 91, 7, 7, 917 respectively, which are all multiples of 7 . Note that (2, 5) and (5, 2) are considered different. In the second sample case, the interesting pairs are (4, 0), (0, 4), (3, 2), (2, 3), (0, 1), (1, 0), (4, 1), (1, 4) , and 6 of these pairs give the number 33 while 2 of them give the numb |
| Codeforces Round #372 Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 25331803 | Spylft | C | March 8, 2017, 12:46 a.m. | OK | GNU C++ | TESTS | 120 | 233 | 25907200 | 2800 | |
| 40983702 | ReaLNero1 | C | July 30, 2018, 6:59 p.m. | OK | GNU C++ | TESTS | 120 | 295 | 23756800 | 2800 | |
| 33229532 | thchuan | C | Dec. 14, 2017, 4:32 a.m. | OK | GNU C++ | TESTS | 120 | 311 | 87040000 | 2800 | |
| 20916035 | KrK | C | Sept. 25, 2016, 9:50 p.m. | OK | GNU C++ | TESTS | 120 | 312 | 27238400 | 2800 | |
| 26414503 | jiyutian | C | April 16, 2017, 1:55 p.m. | OK | GNU C++ | TESTS | 120 | 343 | 15462400 | 2800 | |
| 37855428 | luogu_bot1 | C | May 3, 2018, 7:06 a.m. | OK | GNU C++ | TESTS | 120 | 343 | 22937600 | 2800 | |
| 41157999 | luogu_bot2 | C | Aug. 3, 2018, 1:25 p.m. | OK | GNU C++ | TESTS | 120 | 358 | 18944000 | 2800 | |
| 41571880 | Scut82 | C | Aug. 13, 2018, 11:02 p.m. | OK | GNU C++ | TESTS | 120 | 390 | 34099200 | 2800 | |
| 37855837 | luogu_bot1 | C | May 3, 2018, 7:30 a.m. | OK | GNU C++ | TESTS | 120 | 390 | 37990400 | 2800 | |
| 37854145 | luogu_bot2 | C | May 3, 2018, 5:42 a.m. | OK | GNU C++ | TESTS | 120 | 405 | 22937600 | 2800 | |
| 20715429 | Shik | C | Sept. 17, 2016, 5:31 p.m. | OK | GNU C++11 | TESTS | 120 | 280 | 31027200 | 2800 | |
| 55559519 | RedStar_13 | C | June 14, 2019, 11:51 a.m. | OK | GNU C++11 | TESTS | 120 | 280 | 34508800 | 2800 | |
| 20926293 | ftiasch | C | Sept. 26, 2016, 1:31 p.m. | OK | GNU C++11 | TESTS | 120 | 280 | 39116800 | 2800 | |
| 52084181 | luogu_bot1 | C | March 31, 2019, 1:34 p.m. | OK | GNU C++11 | TESTS | 120 | 296 | 31641600 | 2800 | |
| 24587978 | NagiNikaido | C | Feb. 11, 2017, 11:15 a.m. | OK | GNU C++11 | TESTS | 120 | 312 | 13619200 | 2800 | |
| 52015936 | luogu_bot4 | C | March 30, 2019, 10:34 a.m. | OK | GNU C++11 | TESTS | 120 | 312 | 21401600 | 2800 | |
| 52083618 | 1849285087 | C | March 31, 2019, 1:18 p.m. | OK | GNU C++11 | TESTS | 120 | 312 | 22220800 | 2800 | |
| 47862735 | HiOkami | C | Jan. 3, 2019, 7:26 a.m. | OK | GNU C++11 | TESTS | 120 | 327 | 29388800 | 2800 | |
| 20724278 | fqw | C | Sept. 18, 2016, 3:48 a.m. | OK | GNU C++11 | TESTS | 120 | 327 | 54169600 | 2800 | |
| 20710770 | -XraY- | C | Sept. 17, 2016, 3:41 p.m. | OK | GNU C++11 | TESTS | 120 | 342 | 39833600 | 2800 | |
| 38211114 | cen | C | May 14, 2018, 10:13 a.m. | OK | GNU C++14 | TESTS | 120 | 311 | 35942400 | 2800 | |
| 28749617 | knock_out | C | July 21, 2017, 12:20 p.m. | OK | GNU C++14 | TESTS | 120 | 342 | 54374400 | 2800 | |
| 20777513 | Arpa | C | Sept. 20, 2016, 1:53 p.m. | OK | GNU C++14 | TESTS | 120 | 343 | 32563200 | 2800 | |
| 65829331 | latte0119 | C | Nov. 27, 2019, 1:46 p.m. | OK | GNU C++14 | TESTS | 120 | 343 | 33894400 | 2800 | |
| 20794797 | widelec | C | Sept. 21, 2016, 12:49 p.m. | OK | GNU C++14 | TESTS | 120 | 358 | 43929600 | 2800 | |
| 20727298 | bmerry | C | Sept. 18, 2016, 7:54 a.m. | OK | GNU C++14 | TESTS | 120 | 358 | 46694400 | 2800 | |
| 21238281 | I_Love_Tina | C | Oct. 6, 2016, 2:55 p.m. | OK | GNU C++14 | TESTS | 120 | 358 | 48332800 | 2800 | |
| 33147752 | thchuan | C | Dec. 12, 2017, 7:44 a.m. | OK | GNU C++14 | TESTS | 120 | 358 | 48537600 | 2800 | |
| 20793307 | widelec | C | Sept. 21, 2016, 11:37 a.m. | OK | GNU C++14 | TESTS | 120 | 358 | 50688000 | 2800 | |
| 21238572 | I_Love_Tina | C | Oct. 6, 2016, 3:06 p.m. | OK | GNU C++14 | TESTS | 120 | 390 | 47104000 | 2800 | |
| 68765231 | luogu_bot3 | C | Jan. 14, 2020, 9:40 a.m. | OK | GNU C++17 | TESTS | 120 | 139 | 24268800 | 2800 | |
| 53481961 | Rzepa | C | April 28, 2019, 9:01 p.m. | OK | GNU C++17 | TESTS | 120 | 405 | 19456000 | 2800 | |
| 57756224 | INVWVZ | C | July 25, 2019, 4:23 p.m. | OK | GNU C++17 | TESTS | 120 | 436 | 22937600 | 2800 | |
| 41514445 | FallingStar | C | Aug. 12, 2018, 5:01 a.m. | OK | GNU C++17 | TESTS | 120 | 467 | 33587200 | 2800 | |
| 44409248 | majk | C | Oct. 16, 2018, 4:05 p.m. | OK | GNU C++17 | TESTS | 120 | 499 | 13004800 | 2800 | |
| 44409098 | majk | C | Oct. 16, 2018, 4:02 p.m. | OK | GNU C++17 | TESTS | 120 | 514 | 12595200 | 2800 | |
| 44408099 | majk | C | Oct. 16, 2018, 3:39 p.m. | OK | GNU C++17 | TESTS | 120 | 514 | 13312000 | 2800 | |
| 44410961 | majk | C | Oct. 16, 2018, 4:44 p.m. | OK | GNU C++17 | TESTS | 120 | 529 | 13004800 | 2800 | |
| 44411026 | majk | C | Oct. 16, 2018, 4:46 p.m. | OK | GNU C++17 | TESTS | 120 | 529 | 13414400 | 2800 | |
| 66595713 | hjk1030 | C | Dec. 10, 2019, 2:36 p.m. | OK | GNU C++17 | TESTS | 120 | 576 | 26112000 | 2800 | |
| 21321308 | hama-du | C | Oct. 9, 2016, 3:03 p.m. | OK | Java 8 | TESTS | 120 | 998 | 57241600 | 2800 | |
| 21435020 | fetetriste | C | Oct. 15, 2016, 12:53 a.m. | OK | Java 8 | TESTS | 120 | 1138 | 45875200 | 2800 | |
| 20706891 | mmaxio | C | Sept. 17, 2016, 3:20 p.m. | OK | Java 8 | TESTS | 120 | 1184 | 54374400 | 2800 | |
| 20777166 | Code.coding | C | Sept. 20, 2016, 1:39 p.m. | OK | Java 8 | TESTS | 120 | 1419 | 57856000 | 2800 | |
| 20917653 | sqrtdecompton | C | Sept. 25, 2016, 11:58 p.m. | OK | Java 8 | TESTS | 120 | 2043 | 65740800 | 2800 | |
| 20714573 | DEGwer | C | Sept. 17, 2016, 5:12 p.m. | OK | MS C++ | TESTS | 120 | 654 | 69734400 | 2800 | |
| 20985863 | Carups | C | Sept. 29, 2016, 7:47 a.m. | OK | MS C++ | TESTS | 120 | 763 | 14848000 | 2800 | |
| 20708989 | Taube | C | Sept. 17, 2016, 3:32 p.m. | OK | MS C++ | TESTS | 120 | 780 | 14950400 | 2800 | |
| 20759374 | zyding | C | Sept. 19, 2016, 3:35 p.m. | OK | MS C++ | TESTS | 120 | 1310 | 26828800 | 2800 | |
| 50098041 | vjudge3 | C | Feb. 18, 2019, 1:38 p.m. | OK | MS C++ | TESTS | 120 | 1575 | 125337600 | 2800 | |
| 20778553 | Andrew_Makar | C | Sept. 20, 2016, 2:43 p.m. | OK | MS C++ | TESTS | 120 | 1653 | 36352000 | 2800 | |
| 27174499 | Sereja | C | May 17, 2017, 7:36 a.m. | OK | MS C++ | TESTS | 120 | 2464 | 19456000 | 2800 |
Back to search problems