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 |
---|---|---|---|---|---|---|
1290 | Codeforces Round 616 (Div. 1) | FINISHED | False | 9000 | 151170899 | Feb. 2, 2020, 2:05 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 565 ) | E | Cartesian Tree | PROGRAMMING | data structures | 3200 |
B'Ildar is the algorithm teacher of William and Harris. Today, Ildar is teaching Cartesian Tree. However, Harris is sick, so Ildar is only teaching William. A cartesian tree is a rooted tree, that can be constructed from a sequence of distinct integers. We build the cartesian tree as follows: For example, this is the cartesian tree for the sequence 4, 2, 7, 3, 5, 6, 1 : After teaching what the cartesian tree is, Ildar has assigned homework. He starts with an empty sequence a . In the i -th round, he inserts an element with value i somewhere in a . Then, he asks a question: what is the sum of the sizes of the subtrees for every node in the cartesian tree for the current sequence a ? Node v is in the node u subtree if and only if v = u or v is in the subtree of one of the vertex u children. The size of the subtree of node u is the number of nodes v such that v is in the subtree of u . Ildar will do n rounds in total. The homework is the sequence of answers to the n questions. The next day, Ildar told Harris that he has to complete the homework as well. Harris obtained the final state of the sequence a from William. However, he has no idea how to find the answers to the n questions. Help Harris! The first line contains a single integer n ( 1 <= n <= 150000 ). The second line contains n integers a_1, a_2, ldots, a_n ( 1 <= a_i <= n ). It is guarenteed that each integer from 1 to n appears in the sequence exactly once. Print n lines, i -th line should contain a single integer -- the answer to the i -th question. After the first round, the sequence is 1 . The tree is The answer is 1 . After the second round, the sequence is 2, 1 . The tree is The answer is 2+1=3 . After the third round, the sequence is 2, 1, 3 . The tree is The answer is 2+1+3=6 . After the fourth rou'... |
Codeforces Round #616 Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
70590119 | __santongding | E | Feb. 8, 2020, 8 p.m. | OK | GNU C++11 | TESTS | 59 | 452 | 10240000 | 3200 | |
70112344 | zx2003 | E | Feb. 3, 2020, 6:01 a.m. | OK | GNU C++11 | TESTS | 59 | 499 | 21708800 | 3200 | |
70622593 | HN-001 | E | Feb. 9, 2020, 12:05 p.m. | OK | GNU C++11 | TESTS | 59 | 545 | 22220800 | 3200 | |
70107871 | WZYYN | E | Feb. 3, 2020, 4:08 a.m. | OK | GNU C++11 | TESTS | 59 | 670 | 22220800 | 3200 | |
70076859 | zx2003 | E | Feb. 2, 2020, 4:03 p.m. | OK | GNU C++11 | TESTS | 59 | 686 | 41676800 | 3200 | |
70510758 | Fuyuki | E | Feb. 7, 2020, 2:47 p.m. | OK | GNU C++11 | TESTS | 59 | 780 | 27033600 | 3200 | |
70074704 | fateice | E | Feb. 2, 2020, 3:55 p.m. | OK | GNU C++11 | TESTS | 59 | 826 | 130252800 | 3200 | |
70188602 | mmmod_lqs | E | Feb. 4, 2020, 12:11 a.m. | OK | GNU C++11 | TESTS | 59 | 842 | 30720000 | 3200 | |
70120882 | Rubblsh12345 | E | Feb. 3, 2020, 8:39 a.m. | OK | GNU C++11 | TESTS | 59 | 842 | 34918400 | 3200 | |
70135200 | Isonan | E | Feb. 3, 2020, 11:33 a.m. | OK | GNU C++11 | TESTS | 59 | 873 | 73932800 | 3200 | |
70474000 | yhx-12243 | E | Feb. 7, 2020, 2:35 a.m. | OK | GNU C++14 | TESTS | 59 | 405 | 12595200 | 3200 | |
70111014 | qiqi20021026 | E | Feb. 3, 2020, 5:32 a.m. | OK | GNU C++14 | TESTS | 59 | 420 | 28876800 | 3200 | |
70119769 | cz_xuyixuan | E | Feb. 3, 2020, 8:19 a.m. | OK | GNU C++14 | TESTS | 59 | 701 | 33689600 | 3200 | |
70149933 | wucstdio | E | Feb. 3, 2020, 12:44 p.m. | OK | GNU C++14 | TESTS | 59 | 717 | 28262400 | 3200 | |
70158475 | Benq | E | Feb. 3, 2020, 2:37 p.m. | OK | GNU C++14 | TESTS | 59 | 733 | 40038400 | 3200 | |
70098165 | Amoo_Safar | E | Feb. 2, 2020, 9:18 p.m. | OK | GNU C++14 | TESTS | 59 | 795 | 52940800 | 3200 | |
70100288 | Benq | E | Feb. 2, 2020, 10:46 p.m. | OK | GNU C++14 | TESTS | 59 | 1045 | 15360000 | 3200 | |
70115360 | tmwilliamlin168 | E | Feb. 3, 2020, 7 a.m. | OK | GNU C++14 | TESTS | 59 | 1778 | 227430400 | 3200 | |
70079191 | Cyanic | E | Feb. 2, 2020, 4:13 p.m. | OK | GNU C++14 | TESTS | 59 | 1887 | 31232000 | 3200 | |
70115341 | tmwilliamlin168 | E | Feb. 3, 2020, 6:59 a.m. | OK | GNU C++14 | TESTS | 59 | 1996 | 196300800 | 3200 | |
70339749 | gongsuidashen | E | Feb. 5, 2020, 8:07 a.m. | OK | GNU C++17 | TESTS | 59 | 452 | 28876800 | 3200 | |
70599112 | orzdjq | E | Feb. 9, 2020, 3:17 a.m. | OK | GNU C++17 | TESTS | 59 | 452 | 31334400 | 3200 | |
70362464 | chenkuowen | E | Feb. 5, 2020, 1:32 p.m. | OK | GNU C++17 | TESTS | 59 | 498 | 19251200 | 3200 | |
70088763 | ecnerwala | E | Feb. 2, 2020, 5:44 p.m. | OK | GNU C++17 | TESTS | 59 | 732 | 51200000 | 3200 | |
70214607 | jiangly | E | Feb. 4, 2020, 9:19 a.m. | OK | GNU C++17 | TESTS | 59 | 748 | 6144000 | 3200 | |
70086883 | jiangly | E | Feb. 2, 2020, 5:17 p.m. | OK | GNU C++17 | TESTS | 59 | 811 | 6144000 | 3200 | |
70108970 | ngfam | E | Feb. 3, 2020, 4:40 a.m. | OK | GNU C++17 | TESTS | 59 | 889 | 30720000 | 3200 | |
70123893 | mnbvmar | E | Feb. 3, 2020, 9:30 a.m. | OK | GNU C++17 | TESTS | 59 | 997 | 28774400 | 3200 | |
70085799 | jiangly | E | Feb. 2, 2020, 5:07 p.m. | OK | GNU C++17 | TESTS | 59 | 1013 | 5222400 | 3200 | |
70773716 | hjk1030 | E | Feb. 11, 2020, 8:03 a.m. | OK | GNU C++17 | TESTS | 59 | 1029 | 21811200 | 3200 |
Back to search problems