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 |
---|---|---|---|---|---|---|
1707 | Codeforces Round 808 (Div. 1) | FINISHED | False | 7200 | 79284263 | July 16, 2022, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 743 ) | E | Replace | PROGRAMMING | data structures |
B'You are given an integer array a_1, ldots, a_n , where 1 <= a_i <= n for all i . There 's a "replace" function f which takes a pair of integers (l, r) , where l <= r , as input and outputs the pair f big( (l, r) big)= <= ft( min {a_l,a_{l+1}, ldots,a_r }, , max {a_l,a_{l+1}, ldots,a_r } right). Consider repeated calls of this function. That is, from a starting pair (l, r) we get f big((l, r) big) , then f big(f big((l, r) big) big) , then f big(f big(f big((l, r) big) big) big) , and so on. Now you need to answer q queries. For the i -th query you have two integers l_i and r_i ( 1 <= l_i <= r_i <= n ). You must answer the minimum number of times you must apply the "replace" function to the pair (l_i,r_i) to get (1, n) , or report that it is impossible. The first line contains two positive integers n , q ( 1 <= n,q <= 10^5 ) -- the length of the sequence a and the number of the queries. The second line contains n positive integers a_1,a_2, ldots,a_n ( 1 <= a_i <= n ) -- the sequence a . Each line of the following q lines contains two integers l_i , r_i ( 1 <= l_i <= r_i <= n ) -- the queries. For each query, output the required number of times, or -1 if it is impossible. In the first example, n=5 and a=[2,5,4,1,3] . For the first query: (4,4) to(1,1) to(2,2) to(5,5) to(3,3) to(4,4) to ldots , so it 's impossible to get (1,5) . For the second query, you already have (1,5) . For the third query: (1,4) to(1,5) . For the fourth query: (3,5) to(1,4) to(1,5) . For the fifth query: (4,5) to(1,3) to(2,5) to(1,5) . For the sixth query: (2,3) to(4,5) to(1,3) to(2,5) to(1,5) . '... |
104930 |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
164540899 | thecoderofbd | E | July 16, 2022, 7:03 p.m. | OK | GNU C++14 | TESTS | 42 | 468 | 32051200 | ||
164529024 | Noam527 | E | July 16, 2022, 5:14 p.m. | OK | GNU C++14 | TESTS | 42 | 483 | 287027200 | ||
164525375 | Isonan | E | July 16, 2022, 4:32 p.m. | OK | GNU C++14 | TESTS | 42 | 997 | 389324800 | ||
164540596 | lunchbox | E | July 16, 2022, 6:59 p.m. | OK | GNU C++17 | TESTS | 42 | 358 | 261734400 | ||
164539666 | lunchbox | E | July 16, 2022, 6:48 p.m. | OK | GNU C++17 | TESTS | 42 | 358 | 523776000 | ||
164539731 | lunchbox | E | July 16, 2022, 6:49 p.m. | OK | GNU C++17 | TESTS | 42 | 373 | 262041600 | ||
164546928 | Benq | E | July 16, 2022, 8:34 p.m. | OK | GNU C++17 | TESTS | 42 | 1138 | 806707200 | ||
164538517 | ao_gupta | E | July 16, 2022, 6:34 p.m. | OK | GNU C++17 | TESTS | 42 | 1294 | 389324800 | ||
164540567 | lunchbox | E | July 16, 2022, 6:59 p.m. | OK | GNU C++17 (64) | TESTS | 42 | 358 | 261734400 | ||
164539946 | lunchbox | E | July 16, 2022, 6:51 p.m. | OK | GNU C++17 (64) | TESTS | 42 | 373 | 261734400 | ||
164531480 | errorgorn | E | July 16, 2022, 5:28 p.m. | OK | GNU C++17 (64) | TESTS | 42 | 686 | 129638400 | ||
164574033 | lunchbox | E | July 17, 2022, 5:24 a.m. | OK | GNU C++17 (64) | TESTS | 42 | 701 | 465305600 | ||
164534561 | brunovsky | E | July 16, 2022, 5:55 p.m. | OK | GNU C++20 (64) | TESTS | 42 | 670 | 471449600 | ||
164572469 | monstersqaq | E | July 17, 2022, 5 a.m. | OK | GNU C++20 (64) | TESTS | 42 | 670 | 658124800 | ||
164572518 | monstersqaq | E | July 17, 2022, 5:01 a.m. | OK | GNU C++20 (64) | TESTS | 42 | 685 | 658124800 | ||
164563417 | ecnerwala | E | July 17, 2022, 2:38 a.m. | OK | GNU C++20 (64) | TESTS | 42 | 702 | 142131200 | ||
164534024 | brunovsky | E | July 16, 2022, 5:50 p.m. | OK | GNU C++20 (64) | TESTS | 42 | 1326 | 153600000 |
Back to search problems