Codeforces Round 559 (Div. 1)

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
1158 Codeforces Round 559 (Div. 1) FINISHED False 7200 174151499 May 12, 2019, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 1953 ) C Permutation recovery PROGRAMMING constructive algorithms data structures dfs and similar graphs greedy math sortings 2300

B"Vasya has written some permutation p_1, p_2, ldots, p_n of integers from 1 to n , so for all 1 <= q i <= q n it is true that 1 <= q p_i <= q n and all p_1, p_2, ldots, p_n are different. After that he wrote n numbers next_1, next_2, ldots, next_n . The number next_i is equal to the minimal index i < j <= q n , such that p_j > p_i . If there is no such j let's let's define as next_i = n + 1 . In the evening Vasya went home from school and due to rain, his notebook got wet. Now it is impossible to read some written numbers. Permutation and some values next_i are completely lost! If for some i the value next_i is lost, let's say that next_i = -1 . You are given numbers next_1, next_2, ldots, next_n (maybe some of them are equal to -1 ). Help Vasya to find such permutation p_1, p_2, ldots, p_n of integers from 1 to n , that he can write it to the notebook and all numbers next_i , which are not equal to -1 , will be correct. The first line contains one integer t -- the number of test cases ( 1 <= q t <= q 100 ,000 ). Next 2 cdot t lines contains the description of test cases,two lines for each. The first line contains one integer n -- the length of the permutation, written by Vasya ( 1 <= q n <= q 500 ,000 ). The second line contains n integers next_1, next_2, ldots, next_n , separated by spaces ( next_i = -1 or i < next_i <= q n + 1 ). It is guaranteed, that the sum of n in all test cases doesn't exceed 500 ,000 . In hacks you can only use one test case, so T = 1 . Print T lines, in i -th of them answer to the i -th test case. If there is no such permutations p_1, p_2, ldots, p_n of integers from 1 to n , that Vasya could write, print the only number -1 . In the other case print n different integers p_1, p_2"...

Tutorials

66993

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
54253359 about C May 16, 2019, 6:29 p.m. OK GNU C11 TESTS 100 280 26009600 2300
55610935 ReaLNero1 C June 16, 2019, 5:41 a.m. OK GNU C++11 TESTS 100 108 36147200 2300
54444769 528hby C May 21, 2019, 10:42 a.m. OK GNU C++11 TESTS 100 109 36044800 2300
54444658 528hby C May 21, 2019, 10:39 a.m. OK GNU C++11 TESTS 100 109 36147200 2300
54900739 QAQAutoMaton C June 1, 2019, 6:27 a.m. OK GNU C++11 TESTS 100 109 40243200 2300
54541172 zjczzzjczjczzzjc C May 24, 2019, 1:59 a.m. OK GNU C++11 TESTS 100 109 44032000 2300
54995246 justin_cao C June 2, 2019, 10:29 p.m. OK GNU C++11 TESTS 100 139 19968000 2300
56060355 luogu_bot2 C June 26, 2019, 5:03 a.m. OK GNU C++11 TESTS 100 140 42086400 2300
56060356 vjudge3 C June 26, 2019, 5:03 a.m. OK GNU C++11 TESTS 100 140 42086400 2300
61417474 geniusjoe C Sept. 28, 2019, 10:43 a.m. OK GNU C++11 TESTS 100 171 10035200 2300
64635494 2016wudi C Nov. 10, 2019, 11:28 a.m. OK GNU C++11 TESTS 100 171 10035200 2300
55220943 rainboy C June 6, 2019, 7:32 p.m. OK GNU C++14 TESTS 100 202 14028800 2300
58984293 rhrnald C Aug. 18, 2019, 6:15 a.m. OK GNU C++14 TESTS 100 202 14336000 2300
54067265 ragnarosS C May 13, 2019, 2:07 p.m. OK GNU C++14 TESTS 100 217 5939200 2300
54071305 VladProg C May 13, 2019, 4:24 p.m. OK GNU C++14 TESTS 100 217 13824000 2300
55488746 beginend C June 12, 2019, 9:08 a.m. OK GNU C++14 TESTS 100 217 36454400 2300
54067210 ragnarosS C May 13, 2019, 2:06 p.m. OK GNU C++14 TESTS 100 218 5939200 2300
54077464 Kallaseldor C May 13, 2019, 9:43 p.m. OK GNU C++14 TESTS 100 218 6451200 2300
54047425 GodTe C May 12, 2019, 5:58 p.m. OK GNU C++14 TESTS 100 218 11059200 2300
59404898 Scut82 C Aug. 24, 2019, 1:31 p.m. OK GNU C++14 TESTS 100 218 19968000 2300
58956827 Scut82 C Aug. 17, 2019, 1:23 p.m. OK GNU C++14 TESTS 100 218 19968000 2300
54041360 lesskreker C May 12, 2019, 3:56 p.m. OK GNU C++17 TESTS 100 140 64512000 2300
54085475 kessido C May 14, 2019, 7:05 a.m. OK GNU C++17 TESTS 100 155 5120000 2300
54085631 kessido C May 14, 2019, 7:10 a.m. OK GNU C++17 TESTS 100 156 10854400 2300
54085673 kessido C May 14, 2019, 7:12 a.m. OK GNU C++17 TESTS 100 156 12083200 2300
54040308 MrDindows C May 12, 2019, 3:48 p.m. OK GNU C++17 TESTS 100 202 20275200 2300
54043996 m1sch3f C May 12, 2019, 4:19 p.m. OK GNU C++17 TESTS 100 202 35635200 2300
54082527 sping128 C May 14, 2019, 4:47 a.m. OK GNU C++17 TESTS 100 218 5939200 2300
55596345 daongochaidang C June 15, 2019, 3:15 p.m. OK GNU C++17 TESTS 100 218 6553600 2300
56808355 daongochaidang C July 10, 2019, 2:53 p.m. OK GNU C++17 TESTS 100 218 8396800 2300
54047139 cerberus97 C May 12, 2019, 5:52 p.m. OK GNU C++17 TESTS 100 218 8396800 2300
59620989 ISSAM_LAKOUAM C Aug. 28, 2019, 2:12 p.m. OK Java 8 TESTS 100 296 41267200 2300
54051808 darnley C May 12, 2019, 9:05 p.m. OK Java 8 TESTS 100 296 45875200 2300
54072949 4mda4mda C May 13, 2019, 5:34 p.m. OK Java 8 TESTS 100 311 16384000 2300
54037179 darnley C May 12, 2019, 3:24 p.m. OK Java 8 TESTS 100 327 45875200 2300
54726174 alphacarrot C May 27, 2019, 8:42 p.m. OK Java 8 TESTS 100 405 51916800 2300
54726206 alphacarrot C May 27, 2019, 8:44 p.m. OK Java 8 TESTS 100 405 51916800 2300
54044480 dalt C May 12, 2019, 4:23 p.m. OK Java 8 TESTS 100 499 54272000 2300
55220797 Dukkha C June 6, 2019, 7:26 p.m. OK Java 8 TESTS 100 529 79257600 2300
54033799 uwi C May 12, 2019, 3:04 p.m. OK Java 8 TESTS 100 545 37785600 2300
54038576 mmaxio C May 12, 2019, 3:35 p.m. OK Java 8 TESTS 100 592 74547200 2300
54042852 elizarov C May 12, 2019, 4:09 p.m. OK Kotlin TESTS 100 670 46592000 2300
54140171 TrabajoNocturno C May 14, 2019, 5:20 p.m. OK Mono C# TESTS 100 670 120115200 2300
59755681 j2v C Aug. 30, 2019, 4:27 p.m. OK MS C++ 2017 TESTS 100 311 23142400 2300
68882160 AleksanderBalobanov C Jan. 15, 2020, 7:18 p.m. OK MS C++ 2017 TESTS 100 405 54988800 2300
54043426 whatshisbucket C May 12, 2019, 4:14 p.m. OK PyPy 2 TESTS 100 561 68096000 2300
60051336 beginner1010 C Sept. 5, 2019, 12:45 a.m. OK PyPy 3 TESTS 100 998 76185600 2300

remove filters

Back to search problems