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 |
|---|---|---|---|---|---|---|
| 812 | Codeforces Round 417 (Div. 2) | FINISHED | False | 7200 | 280079123 | June 1, 2017, 2:15 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 1316 ) | E | Sagheer and Apple Tree | PROGRAMMING | games trees | 2200 |
Sagheer is playing a game with his best friend Soliman. He brought a tree with n nodes numbered from 1 to n and rooted at node 1 . The i -th node has a i apples. This tree has a special property: the lengths of all paths from the root to any leaf have the same parity (i.e. all paths have even length or all paths have odd length). Sagheer and Soliman will take turns to play. Soliman will make the first move. The player who can't make a move loses. In each move, the current player will pick a single node, take a non-empty subset of apples from it and do one of the following two things: eat the apples, if the node is a leaf. move the apples to one of the children, if the node is non-leaf. Before Soliman comes to start playing, Sagheer will make exactly one change to the tree. He will pick two different nodes u and v and swap the apples of u with the apples of v . Can you help Sagheer count the number of ways to make the swap (i.e. to choose u and v ) after which he will win the game if both players play optimally? ( u , v ) and ( v , u ) are considered to be the same pair. The first line will contain one integer n ( 2 ≤ n ≤ 10 5 ) — the number of nodes in the apple tree. The second line will contain n integers a 1 , a 2 , ..., a n ( 1 ≤ a i ≤ 10 7 ) — the number of apples on each node of the tree. The third line will contain n - 1 integers p 2 , p 3 , ..., p n ( 1 ≤ p i ≤ n ) — the parent of each node of the tree. Node i has parent p i (for 2 ≤ i ≤ n ). Node 1 is the root of the tree. It is guaranteed that the input describes a valid tree, and the lengths of all paths from the root to any leaf will have the same parity. On a single line, print the number of different pairs of nodes ( u , v ) , u ≠ v such that if they start playing after swapping the apples of both nodes, Sagheer will win the game. ( u , v ) and ( v , u ) are considered to be the same pair. In the first sample, Sagheer can only win if he swapped node 1 with node 3 . In this case, both leaves w |
| [Editorial] Codeforces Round #417 (Div. 2) |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 27506452 | chihiro | E | June 1, 2017, 5:26 p.m. | OK | GNU C++ | TESTS | 76 | 31 | 5836800 | 2200 | |
| 27521701 | lujiaju | E | June 2, 2017, 10:54 a.m. | OK | GNU C++ | TESTS | 76 | 31 | 72396800 | 2200 | |
| 27503067 | songyiqun | E | June 1, 2017, 4:09 p.m. | OK | GNU C++ | TESTS | 76 | 31 | 84480000 | 2200 | |
| 27572932 | AkaneSasu | E | June 4, 2017, 11:24 p.m. | OK | GNU C++ | TESTS | 76 | 31 | 85913600 | 2200 | |
| 27560919 | King_of_Paladins | E | June 4, 2017, 10:31 a.m. | OK | GNU C++ | TESTS | 76 | 31 | 85913600 | 2200 | |
| 27495067 | jiyutian | E | June 1, 2017, 3:12 p.m. | OK | GNU C++ | TESTS | 76 | 31 | 86323200 | 2200 | |
| 27564658 | I_Love_XBy | E | June 4, 2017, 1:18 p.m. | OK | GNU C++ | TESTS | 76 | 31 | 115814400 | 2200 | |
| 27519437 | XuYipei | E | June 2, 2017, 9 a.m. | OK | GNU C++ | TESTS | 76 | 31 | 115814400 | 2200 | |
| 27517385 | ACMLCZH | E | June 2, 2017, 7 a.m. | OK | GNU C++ | TESTS | 76 | 31 | 125235200 | 2200 | |
| 27607212 | ToErr | E | June 6, 2017, 7:09 a.m. | OK | GNU C++ | TESTS | 76 | 46 | 8908800 | 2200 | |
| 27563904 | AtlantisLove | E | June 4, 2017, 12:30 p.m. | OK | GNU C++11 | TESTS | 76 | 15 | 45465600 | 2200 | |
| 27533636 | Cherries | E | June 3, 2017, 1:36 a.m. | OK | GNU C++11 | TESTS | 76 | 30 | 87347200 | 2200 | |
| 27613456 | supy | E | June 6, 2017, 12:26 p.m. | OK | GNU C++11 | TESTS | 76 | 31 | 75264000 | 2200 | |
| 27512248 | I_always_love_cc | E | June 2, 2017, 12:03 a.m. | OK | GNU C++11 | TESTS | 76 | 31 | 78540800 | 2200 | |
| 27512146 | cchandsome | E | June 1, 2017, 11:51 p.m. | OK | GNU C++11 | TESTS | 76 | 31 | 78540800 | 2200 | |
| 27493766 | _luckyE | E | June 1, 2017, 3:03 p.m. | OK | GNU C++11 | TESTS | 76 | 31 | 143667200 | 2200 | |
| 27566348 | w_e_i_ | E | June 4, 2017, 2:58 p.m. | OK | GNU C++11 | TESTS | 76 | 46 | 3993600 | 2200 | |
| 27561650 | yp0413150208 | E | June 4, 2017, 11:15 a.m. | OK | GNU C++11 | TESTS | 76 | 46 | 4812800 | 2200 | |
| 27574937 | keke_haha | E | June 5, 2017, 3:38 a.m. | OK | GNU C++11 | TESTS | 76 | 46 | 7168000 | 2200 | |
| 27515578 | llgyc | E | June 2, 2017, 5:09 a.m. | OK | GNU C++11 | TESTS | 76 | 46 | 8806400 | 2200 | |
| 27505483 | Egor.Lifar | E | June 1, 2017, 5:01 p.m. | OK | GNU C++14 | TESTS | 76 | 31 | 167014400 | 2200 | |
| 29639604 | whzzt | E | Aug. 21, 2017, 9:06 a.m. | OK | GNU C++14 | TESTS | 76 | 46 | 88678400 | 2200 | |
| 27508145 | OMRailgun | E | June 1, 2017, 6:28 p.m. | OK | GNU C++14 | TESTS | 76 | 46 | 162304000 | 2200 | |
| 27505389 | I_love_Tvoya_Mamasha | E | June 1, 2017, 4:59 p.m. | OK | GNU C++14 | TESTS | 76 | 46 | 162304000 | 2200 | |
| 27501957 | 0MRailgun | E | June 1, 2017, 4:01 p.m. | OK | GNU C++14 | TESTS | 76 | 46 | 162304000 | 2200 | |
| 27631358 | I_Love_Umirzhanova_Amina | E | June 7, 2017, 11:25 a.m. | OK | GNU C++14 | TESTS | 76 | 61 | 162304000 | 2200 | |
| 27501023 | Rapiz | E | June 1, 2017, 3:54 p.m. | OK | GNU C++14 | TESTS | 76 | 62 | 3686400 | 2200 | |
| 28211023 | NiroBC | E | July 2, 2017, 1:12 p.m. | OK | GNU C++14 | TESTS | 76 | 62 | 3891200 | 2200 | |
| 27499260 | natsugiri | E | June 1, 2017, 3:40 p.m. | OK | GNU C++14 | TESTS | 76 | 62 | 5120000 | 2200 | |
| 27576612 | XenoAmess | E | June 5, 2017, 6:07 a.m. | OK | GNU C++14 | TESTS | 76 | 62 | 5324800 | 2200 | |
| 59820439 | StarCuriosity | E | Aug. 31, 2019, 5:07 p.m. | OK | GNU C++17 | TESTS | 76 | 77 | 10649600 | 2200 | |
| 51434906 | oToToT | E | March 18, 2019, 5:34 a.m. | OK | GNU C++17 | TESTS | 76 | 78 | 9523200 | 2200 | |
| 69556111 | cutmdo | E | Jan. 26, 2020, 8:53 a.m. | OK | GNU C++17 | TESTS | 76 | 78 | 10649600 | 2200 | |
| 39184067 | Lucky__Boy | E | June 12, 2018, 7:51 a.m. | OK | GNU C++17 | TESTS | 76 | 78 | 11059200 | 2200 | |
| 65455984 | Pankin | E | Nov. 20, 2019, 8:35 p.m. | OK | GNU C++17 | TESTS | 76 | 78 | 17100800 | 2200 | |
| 57663405 | maxnguyen | E | July 24, 2019, 3:08 p.m. | OK | GNU C++17 | TESTS | 76 | 93 | 7168000 | 2200 | |
| 59965457 | emthrm | E | Sept. 3, 2019, 8:13 p.m. | OK | GNU C++17 | TESTS | 76 | 93 | 12595200 | 2200 | |
| 62589913 | Phortox | E | Oct. 14, 2019, 8:31 p.m. | OK | GNU C++17 | TESTS | 76 | 93 | 13414400 | 2200 | |
| 41654720 | vjudge4 | E | Aug. 16, 2018, 1:48 p.m. | OK | GNU C++17 | TESTS | 76 | 93 | 16588800 | 2200 | |
| 50659787 | chinmay0906 | E | March 1, 2019, 10:01 p.m. | OK | GNU C++17 | TESTS | 76 | 93 | 50278400 | 2200 | |
| 27771733 | donli | E | June 14, 2017, 9:56 a.m. | OK | Java 8 | TESTS | 76 | 187 | 65536000 | 2200 | |
| 27539712 | milap_shah | E | June 3, 2017, 8:51 a.m. | OK | Java 8 | TESTS | 76 | 218 | 194355200 | 2200 | |
| 27495867 | uwi | E | June 1, 2017, 3:17 p.m. | OK | Java 8 | TESTS | 76 | 218 | 194355200 | 2200 | |
| 27628678 | wolfib | E | June 7, 2017, 8:38 a.m. | OK | Java 8 | TESTS | 76 | 233 | 33280000 | 2200 | |
| 29763120 | Darth_Jar_Jar_Binks | E | Aug. 24, 2017, 10:31 p.m. | OK | Java 8 | TESTS | 76 | 249 | 7168000 | 2200 | |
| 28411128 | PrakharJain | E | July 10, 2017, 3:49 p.m. | OK | Java 8 | TESTS | 76 | 249 | 35635200 | 2200 | |
| 27580279 | beroul | E | June 5, 2017, 10:10 a.m. | OK | Java 8 | TESTS | 76 | 249 | 244940800 | 2200 | |
| 27502051 | iakovlev.zakhar | E | June 1, 2017, 4:01 p.m. | OK | Java 8 | TESTS | 76 | 264 | 32358400 | 2200 | |
| 27666061 | safarisoul | E | June 8, 2017, 7:58 a.m. | OK | Java 8 | TESTS | 76 | 280 | 18124800 | 2200 | |
| 27515846 | U_Square | E | June 2, 2017, 5:26 a.m. | OK | Java 8 | TESTS | 76 | 280 | 66867200 | 2200 | |
| 27535775 | hamayanhamayan | E | June 3, 2017, 4:36 a.m. | OK | Kotlin | TESTS | 76 | 264 | 30720000 | 2200 | |
| 27529996 | peregrinus | E | June 2, 2017, 6:37 p.m. | OK | Mono C# | TESTS | 76 | 140 | 104550400 | 2200 | |
| 27494193 | lucyanna2018 | E | June 1, 2017, 3:06 p.m. | OK | MS C++ | TESTS | 76 | 62 | 8396800 | 2200 | |
| 27508309 | P___ | E | June 1, 2017, 6:34 p.m. | OK | MS C++ | TESTS | 76 | 109 | 10649600 | 2200 | |
| 27541990 | TadijaSebez | E | June 3, 2017, 11:10 a.m. | OK | MS C++ | TESTS | 76 | 187 | 85913600 | 2200 | |
| 27532655 | Darooha | E | June 2, 2017, 11:04 p.m. | OK | Ocaml | TESTS | 76 | 93 | 3891200 | 2200 | |
| 27504964 | JaniceV | E | June 1, 2017, 4:49 p.m. | OK | PyPy 2 | TESTS | 76 | 171 | 13107200 | 2200 | |
| 27565885 | DDDDDDDDDDDDDDDDDDDDDDDD | E | June 4, 2017, 2:26 p.m. | OK | PyPy 2 | TESTS | 76 | 171 | 16486400 | 2200 | |
| 27504838 | JaniceV | E | June 1, 2017, 4:47 p.m. | OK | PyPy 2 | TESTS | 76 | 436 | 171008000 | 2200 | |
| 27499935 | nwi | E | June 1, 2017, 3:45 p.m. | OK | Python 2 | TESTS | 76 | 233 | 17920000 | 2200 | |
| 27565889 | DDDDDDDDDDDDDDDDDDDDDDDD | E | June 4, 2017, 2:26 p.m. | OK | Python 2 | TESTS | 76 | 311 | 20684800 | 2200 | |
| 27606445 | sragavan | E | June 6, 2017, 6:24 a.m. | OK | Python 2 | TESTS | 76 | 343 | 9728000 | 2200 | |
| 40260059 | Ali_Pi | E | July 13, 2018, 11:50 a.m. | OK | Python 2 | TESTS | 76 | 374 | 17817600 | 2200 | |
| 27966747 | J_X | E | June 22, 2017, 1:53 p.m. | OK | Python 2 | TESTS | 76 | 452 | 15872000 | 2200 | |
| 42880623 | rookzeno | E | Sept. 15, 2018, 6:35 a.m. | OK | Python 3 | TESTS | 76 | 358 | 9932800 | 2200 | |
| 27519733 | sas | E | June 2, 2017, 9:14 a.m. | OK | Python 3 | TESTS | 76 | 374 | 21196800 | 2200 |
Back to search problems