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 |
---|---|---|---|---|---|---|
1696 | Codeforces Global Round 21 | FINISHED | False | 8100 | 81098663 | June 25, 2022, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 5564 ) | D | Permutation Graph | PROGRAMMING | binary search constructive algorithms data structures greedy shortest paths trees |
B"A permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation ( 2 appears twice in the array) and [1,3,4] is also not a permutation ( n=3 but there is 4 in the array). You are given a permutation of 1,2, ... ,n , [a_1,a_2, ... ,a_n] . For integers i , j such that 1 <= i<j <= n , define operatorname{mn}(i,j) as min limits_{k=i}^j a_k , and define operatorname{mx}(i,j) as max limits_{k=i}^j a_k . Let us build an undirected graph of n vertices, numbered 1 to n . For every pair of integers 1 <= i<j <= n , if operatorname{mn}(i,j)=a_i and operatorname{mx}(i,j)=a_j both holds, or operatorname{mn}(i,j)=a_j and operatorname{mx}(i,j)=a_i both holds, add an undirected edge of length 1 between vertices i and j . In this graph, find the length of the shortest path from vertex 1 to vertex n . We can prove that 1 and n will always be connected via some path, so a shortest path always exists. Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 5 cdot 10^4 ). Description of the test cases follows. The first line of each test case contains one integer n ( 1 <= n <= 2.5 cdot 10^5 ). The second line of each test case contains n integers a_1 , a_2 , ldots , a_n ( 1 <= a_i <= n ). It's guaranteed that a is a permutation of 1 , 2 , ... , n . It is guaranteed that the sum of n over all test cases does not exceed 5 cdot 10^5 . For each test case, print a single line containing one integer -- the length of the shortest path from 1 to n . The following are illustrations of constructed graphs in example test cases. "... |
Editorial of Codeforces Global Round 21 |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
161831925 | Tdyx | D | June 26, 2022, 5:54 a.m. | OK | C# 8 | TESTS | 24 | 155 | 49254400 | ||
161815534 | tgehr | D | June 25, 2022, 9:44 p.m. | OK | D | TESTS | 24 | 139 | 27545600 | ||
161815641 | tgehr | D | June 25, 2022, 9:48 p.m. | OK | D | TESTS | 24 | 140 | 27545600 | ||
161810748 | tgehr | D | June 25, 2022, 7:52 p.m. | OK | D | TESTS | 24 | 1184 | 79564800 | ||
161813785 | NenadDapic | D | June 25, 2022, 8:57 p.m. | OK | FPC | TESTS | 24 | 217 | 3072000 | ||
161813629 | NenadDapic | D | June 25, 2022, 8:52 p.m. | OK | FPC | TESTS | 24 | 218 | 4096000 | ||
161791949 | chro4896 | D | June 25, 2022, 4:32 p.m. | OK | GNU C11 | TESTS | 24 | 264 | 8704000 | ||
161789695 | CQYZWJH | D | June 25, 2022, 4:23 p.m. | OK | GNU C++14 | TESTS | 24 | 62 | 7372800 | ||
161805994 | tokitsukaze | D | June 25, 2022, 6:38 p.m. | OK | GNU C++14 | TESTS | 24 | 62 | 9113600 | ||
161802044 | wbscd | D | June 25, 2022, 5:54 p.m. | OK | GNU C++14 | TESTS | 24 | 109 | 13107200 | ||
161820277 | duoluoluo | D | June 26, 2022, 12:48 a.m. | OK | GNU C++14 | TESTS | 24 | 124 | 4096000 | ||
161818306 | _void | D | June 25, 2022, 11:24 p.m. | OK | GNU C++14 | TESTS | 24 | 124 | 4096000 | ||
161800959 | gopikrishna000 | D | June 25, 2022, 5:44 p.m. | OK | GNU C++14 | TESTS | 24 | 124 | 4096000 | ||
161800247 | d-joker | D | June 25, 2022, 5:40 p.m. | OK | GNU C++14 | TESTS | 24 | 124 | 4096000 | ||
161823170 | dhruvrathi04 | D | June 26, 2022, 2:27 a.m. | OK | GNU C++14 | TESTS | 24 | 124 | 4096000 | ||
161815753 | sievra | D | June 25, 2022, 9:51 p.m. | OK | GNU C++14 | TESTS | 24 | 124 | 4710400 | ||
161815820 | sievra | D | June 25, 2022, 9:52 p.m. | OK | GNU C++14 | TESTS | 24 | 124 | 4710400 | ||
161808776 | Bobocan | D | June 25, 2022, 7:18 p.m. | OK | GNU C++17 | TESTS | 24 | 31 | 6553600 | ||
161788430 | kwoncycle | D | June 25, 2022, 4:18 p.m. | OK | GNU C++17 | TESTS | 24 | 93 | 5529600 | ||
161795304 | ElaineHuang | D | June 25, 2022, 4:44 p.m. | OK | GNU C++17 | TESTS | 24 | 124 | 2048000 | ||
161814957 | twp | D | June 25, 2022, 9:27 p.m. | OK | GNU C++17 | TESTS | 24 | 124 | 3072000 | ||
161787807 | AlexanderL | D | June 25, 2022, 4:16 p.m. | OK | GNU C++17 | TESTS | 24 | 124 | 5120000 | ||
161808923 | rohitkumar0510 | D | June 25, 2022, 7:20 p.m. | OK | GNU C++17 | TESTS | 24 | 124 | 6041600 | ||
161821061 | mohamedeltair | D | June 26, 2022, 1:19 a.m. | OK | GNU C++17 | TESTS | 24 | 124 | 7065600 | ||
161815453 | hyturing | D | June 25, 2022, 9:42 p.m. | OK | GNU C++17 | TESTS | 24 | 124 | 7065600 | ||
161806502 | mati9977 | D | June 25, 2022, 6:45 p.m. | OK | GNU C++17 | TESTS | 24 | 124 | 7065600 | ||
161818706 | LCPlayer | D | June 25, 2022, 11:41 p.m. | OK | GNU C++17 | TESTS | 24 | 124 | 10035200 | ||
161805142 | zitraks | D | June 25, 2022, 6:27 p.m. | OK | GNU C++17 (64) | TESTS | 24 | 78 | 33280000 | ||
161829180 | GreyMatter14 | D | June 26, 2022, 5:03 a.m. | OK | GNU C++17 (64) | TESTS | 24 | 93 | 4300800 | ||
161813737 | neal | D | June 25, 2022, 8:55 p.m. | OK | GNU C++17 (64) | TESTS | 24 | 93 | 6348800 | ||
161787123 | Dio707 | D | June 25, 2022, 4:14 p.m. | OK | GNU C++17 (64) | TESTS | 24 | 93 | 7270400 | ||
161811353 | kira11 | D | June 25, 2022, 8:04 p.m. | OK | GNU C++17 (64) | TESTS | 24 | 93 | 7270400 | ||
161820964 | OnMyZenith | D | June 26, 2022, 1:14 a.m. | OK | GNU C++17 (64) | TESTS | 24 | 93 | 7475200 | ||
161818086 | nohaxjustsoflo | D | June 25, 2022, 11:14 p.m. | OK | GNU C++17 (64) | TESTS | 24 | 93 | 10240000 | ||
161826208 | KKT_89 | D | June 26, 2022, 3:51 a.m. | OK | GNU C++17 (64) | TESTS | 24 | 93 | 10240000 | ||
161808533 | Ayalla | D | June 25, 2022, 7:15 p.m. | OK | GNU C++17 (64) | TESTS | 24 | 93 | 12083200 | ||
161827175 | Trying_004 | D | June 26, 2022, 4:16 a.m. | OK | GNU C++17 (64) | TESTS | 24 | 93 | 13209600 | ||
161823886 | tokitsukaze | D | June 26, 2022, 2:50 a.m. | OK | GNU C++20 (64) | TESTS | 24 | 46 | 9216000 | ||
161801438 | Lhohelhohehmm | D | June 25, 2022, 5:49 p.m. | OK | GNU C++20 (64) | TESTS | 24 | 62 | 3276800 | ||
161803557 | Kotoblepass | D | June 25, 2022, 6:09 p.m. | OK | GNU C++20 (64) | TESTS | 24 | 62 | 4300800 | ||
161804092 | AS01 | D | June 25, 2022, 6:15 p.m. | OK | GNU C++20 (64) | TESTS | 24 | 62 | 4300800 | ||
161814524 | Skillful_Wanderer | D | June 25, 2022, 9:15 p.m. | OK | GNU C++20 (64) | TESTS | 24 | 62 | 6246400 | ||
161830100 | lockdown | D | June 26, 2022, 5:21 a.m. | OK | GNU C++20 (64) | TESTS | 24 | 62 | 6348800 | ||
161791864 | ashish801 | D | June 25, 2022, 4:31 p.m. | OK | GNU C++20 (64) | TESTS | 24 | 77 | 4300800 | ||
161812302 | bhavya2921 | D | June 25, 2022, 8:23 p.m. | OK | GNU C++20 (64) | TESTS | 24 | 77 | 7680000 | ||
161803397 | Kotoblepass | D | June 25, 2022, 6:08 p.m. | OK | GNU C++20 (64) | TESTS | 24 | 77 | 9216000 | ||
161830467 | agrawalpiyush | D | June 26, 2022, 5:28 a.m. | OK | GNU C++20 (64) | TESTS | 24 | 77 | 12288000 | ||
161801457 | LXL | D | June 25, 2022, 5:49 p.m. | OK | Go | TESTS | 24 | 1154 | 146739200 | ||
161806516 | dunkingdonuts | D | June 25, 2022, 6:45 p.m. | OK | Java 11 | TESTS | 24 | 405 | 60928000 | ||
161808149 | tusharpruth | D | June 25, 2022, 7:09 p.m. | OK | Java 11 | TESTS | 24 | 421 | 47923200 | ||
161813058 | vishesh20155 | D | June 25, 2022, 8:39 p.m. | OK | Java 11 | TESTS | 24 | 514 | 29593600 | ||
161818259 | dzhi | D | June 25, 2022, 11:22 p.m. | OK | Java 11 | TESTS | 24 | 607 | 33894400 | ||
161830609 | mufinhead | D | June 26, 2022, 5:31 a.m. | OK | Java 11 | TESTS | 24 | 748 | 70144000 | ||
161793743 | bwang1008 | D | June 25, 2022, 4:39 p.m. | OK | Java 11 | TESTS | 24 | 779 | 26624000 | ||
161825999 | humwawe | D | June 26, 2022, 3:45 a.m. | OK | Java 11 | TESTS | 24 | 1029 | 108134400 | ||
161795800 | ADvidwans | D | June 25, 2022, 4:46 p.m. | OK | Java 8 | TESTS | 24 | 592 | 90726400 | ||
161800242 | EndlessVoid | D | June 25, 2022, 5:40 p.m. | OK | Java 8 | TESTS | 24 | 919 | 40960000 | ||
161815405 | UniversalAdmin | D | June 25, 2022, 9:41 p.m. | OK | Java 8 | TESTS | 24 | 1372 | 275763200 | ||
161815366 | UniversalAdmin | D | June 25, 2022, 9:40 p.m. | OK | Java 8 | TESTS | 24 | 1372 | 275763200 | ||
161795349 | UniversalAdmin | D | June 25, 2022, 4:44 p.m. | OK | Java 8 | TESTS | 24 | 1372 | 275763200 | ||
161799724 | invincible777 | D | June 25, 2022, 5:37 p.m. | OK | Java 8 | TESTS | 24 | 1419 | 165478400 | ||
161790711 | naitikvarshney | D | June 25, 2022, 4:27 p.m. | OK | Java 8 | TESTS | 24 | 1684 | 117145600 | ||
161799348 | Omar_Mohammad | D | June 25, 2022, 5:35 p.m. | OK | Java 8 | TESTS | 24 | 1731 | 168960000 | ||
161830877 | zyxw | D | June 26, 2022, 5:36 a.m. | OK | Kotlin 1.6 | TESTS | 24 | 702 | 60620800 | ||
161813902 | SlavaG | D | June 25, 2022, 9 p.m. | OK | Kotlin 1.6 | TESTS | 24 | 920 | 59187200 | ||
161807606 | Bossusuprem | D | June 25, 2022, 7 p.m. | OK | MS C++ 2017 | TESTS | 24 | 498 | 13619200 | ||
161796891 | Alexey | D | June 25, 2022, 4:49 p.m. | OK | MS C++ 2017 | TESTS | 24 | 530 | 5120000 | ||
161793354 | Viktor36 | D | June 25, 2022, 4:37 p.m. | OK | MS C++ 2017 | TESTS | 24 | 607 | 24985600 | ||
161803645 | 1_2_3_4_5_9 | D | June 25, 2022, 6:10 p.m. | OK | PyPy 2 | TESTS | 24 | 186 | 48332800 | ||
161799212 | myotra | D | June 25, 2022, 5:35 p.m. | OK | PyPy 3 | TESTS | 24 | 530 | 52019200 | ||
161793992 | mouryasatyam | D | June 25, 2022, 4:40 p.m. | OK | PyPy 3 | TESTS | 24 | 1185 | 104140800 | ||
161789996 | Amiy_Tiwari | D | June 25, 2022, 4:24 p.m. | OK | PyPy 3 | TESTS | 24 | 1325 | 157593600 | ||
161802163 | namans777 | D | June 25, 2022, 5:55 p.m. | OK | PyPy 3 | TESTS | 24 | 1356 | 72908800 | ||
161802277 | namans777 | D | June 25, 2022, 5:56 p.m. | OK | PyPy 3 | TESTS | 24 | 1435 | 77004800 | ||
161804059 | yoyo_124 | D | June 25, 2022, 6:15 p.m. | OK | PyPy 3-64 | TESTS | 24 | 389 | 219545600 | ||
161790445 | govindp47 | D | June 25, 2022, 4:26 p.m. | OK | PyPy 3-64 | TESTS | 24 | 452 | 79769600 | ||
161792180 | satyamshrma | D | June 25, 2022, 4:33 p.m. | OK | PyPy 3-64 | TESTS | 24 | 529 | 75980800 | ||
161813290 | MrDrogon | D | June 25, 2022, 8:44 p.m. | OK | PyPy 3-64 | TESTS | 24 | 748 | 83763200 | ||
161796040 | Adroit_001 | D | June 25, 2022, 4:47 p.m. | OK | PyPy 3-64 | TESTS | 24 | 763 | 89804800 | ||
161832171 | abhijeet.panihar.cse20 | D | June 26, 2022, 5:58 a.m. | OK | PyPy 3-64 | TESTS | 24 | 1013 | 82227200 | ||
161802629 | tryharda | D | June 25, 2022, 5:59 p.m. | OK | PyPy 3-64 | TESTS | 24 | 1029 | 82739200 | ||
161789376 | OpKos | D | June 25, 2022, 4:22 p.m. | OK | PyPy 3-64 | TESTS | 24 | 1200 | 82739200 | ||
161792609 | _Temeraire | D | June 25, 2022, 4:34 p.m. | OK | PyPy 3-64 | TESTS | 24 | 1216 | 89292800 | ||
161792243 | Versern | D | June 25, 2022, 4:33 p.m. | OK | PyPy 3-64 | TESTS | 24 | 1248 | 75468800 | ||
161804105 | d_hsu | D | June 25, 2022, 6:15 p.m. | OK | Python 3 | TESTS | 24 | 1559 | 28057600 | ||
161801145 | namans777 | D | June 25, 2022, 5:46 p.m. | OK | Python 3 | TESTS | 24 | 1808 | 61644800 | ||
161800407 | Thallium54 | D | June 25, 2022, 5:41 p.m. | OK | Rust 2021 | TESTS | 24 | 46 | 10547200 | ||
161805657 | magnus.hegdahl | D | June 25, 2022, 6:33 p.m. | OK | Rust 2021 | TESTS | 24 | 124 | 33280000 |
Back to search problems