Codeforces Round 1059 (Div. 3)

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
2162 Codeforces Round 1059 (Div. 3) FINISHED False 8100 15693923 Oct. 17, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 309 ) H Beautiful Problem PROGRAMMING dp

For an array (a) of length (n) and three integers (x), (l), and (r)((1 \le l \le r \le n)), define: () f(a,x,l,r) = \begin{cases} 0, & \text{if} & (x-\min_{j=l}^{r}(a_j)) \cdot (x-\max_{j=l}^{r}(a_j))) < 0 \\ 1, & \text{if} & (x-\min_{j=l}^{r}(a_j)) \cdot (x-\max_{j=l}^{r}(a_j))) \ge 0 \end{cases} () You are given an array (a) of length (n) ((1 \le a_i \le n)), and (m) intervals (l_i, r_i) ((1 \le l_i \le r_i \le n)). For each (x=1, 2, \dots, n), answer the following question independently : Does there exist a rearrangement (a') of (a), such that for all (1 \le i \le m), (f(a',x,l_i,r_i) = 1)? The first line contains a single integer (t) ((1 \le t \le 2 \cdot 10^4)) — the number of test cases. Description of each testcase follows. The first line contains two integers (n) and (m) ((2 \le n \le 2000), (1 \le m \le 2000)). The next line contains (n) space-separated integers (a_1, a_2, \cdots, a_n) ((1 \le a_i \le n)). The next (m) lines each contain two space-separated integers (l_i, r_i) ((1 \le l_i \le r_i \le n)), each denoting an interval. It is guaranteed that the sum of (n^2) and the sum of (m^2) over all test cases does not exceed (4 \cdot 10^6), respectively. For each test case, output a binary string (s). For (x=1,2,\ldots,n), (s_x=1) only if there exists a rearrangement (a') of (a), such that for all (1 \le i \le m), (f(a',x,l_i,r_i) = 1). Otherwise, (s_x=0). In the first test case, For (x=1), one valid rearrangement is (a'=1,1,3,4). For (x=2), there is no rearrangement (a') of (a) satisfying (f(a',2,1,2)=f(a',2,2,4)=1). For (x=3), the only valid rearrangement is (a'=4,3,1,1). For (x=4), one valid rearrangement is (a'=1,1,3,4).

Tutorials

Codeforces Round 1059 (Div. 3) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
344499505 road_to_success H Oct. 18, 2025, 1:02 p.m. OK C++17 (GCC 7-32) TESTS 30 218 64204800
344563673 Eusha_Ibna_Akbor H Oct. 18, 2025, 8:36 p.m. OK C++17 (GCC 7-32) TESTS 30 233 34508800
344436979 shanks.akagami H Oct. 18, 2025, 5:43 a.m. OK C++17 (GCC 7-32) TESTS 30 249 60416000
344494565 iamsauravsavvy H Oct. 18, 2025, 12:33 p.m. OK C++17 (GCC 7-32) TESTS 30 249 64512000
344422539 suhaskumar H Oct. 18, 2025, 2:58 a.m. OK C++17 (GCC 7-32) TESTS 30 312 65228800
344540126 haha1324 H Oct. 18, 2025, 5:05 p.m. OK C++17 (GCC 7-32) TESTS 30 781 144588800
344432804 Namii_Kaze H Oct. 18, 2025, 5:05 a.m. OK C++20 (GCC 13-64) TESTS 30 156 64512000
344418376 300iq H Oct. 18, 2025, 1:48 a.m. OK C++20 (GCC 13-64) TESTS 30 187 32358400
344546888 OG_Matveychick1 H Oct. 18, 2025, 5:52 p.m. OK C++20 (GCC 13-64) TESTS 30 202 64102400
344516343 MaksimXD H Oct. 18, 2025, 2:36 p.m. OK C++20 (GCC 13-64) TESTS 30 234 64614400
344536525 ALAov H Oct. 18, 2025, 4:42 p.m. OK C++20 (GCC 13-64) TESTS 30 484 97075200
344497812 Treks H Oct. 18, 2025, 12:52 p.m. OK C++20 (GCC 13-64) TESTS 30 1093 142336000
344528962 Arjav1008 H Oct. 18, 2025, 3:53 p.m. OK C++23 (GCC 14-64, msys2) TESTS 30 156 48230400
344428228 Yuichiro17 H Oct. 18, 2025, 4:16 a.m. OK C++23 (GCC 14-64, msys2) TESTS 30 171 30720000
344427460 Suwan H Oct. 18, 2025, 4:07 a.m. OK C++23 (GCC 14-64, msys2) TESTS 30 171 32256000
344510392 fogrevelation H Oct. 18, 2025, 2:04 p.m. OK C++23 (GCC 14-64, msys2) TESTS 30 171 36966400
344511706 BaarishBoy H Oct. 18, 2025, 2:11 p.m. OK C++23 (GCC 14-64, msys2) TESTS 30 171 64512000
344549906 kusumakilari2 H Oct. 18, 2025, 6:15 p.m. OK C++23 (GCC 14-64, msys2) TESTS 30 186 30720000
344433385 hungchi17 H Oct. 18, 2025, 5:11 a.m. OK C++23 (GCC 14-64, msys2) TESTS 30 186 32256000
344428956 NMHsw_cfs H Oct. 18, 2025, 4:24 a.m. OK C++23 (GCC 14-64, msys2) TESTS 30 186 60518400
344427386 gooonn H Oct. 18, 2025, 4:06 a.m. OK C++23 (GCC 14-64, msys2) TESTS 30 186 60518400
344584199 NQBH H Oct. 19, 2025, 4:41 a.m. OK C++23 (GCC 14-64, msys2) TESTS 30 202 60416000
344528192 ICPCCode H Oct. 18, 2025, 3:48 p.m. OK GNU C11 TESTS 30 187 64512000
344429932 Ab_hoga_real_Cumback H Oct. 18, 2025, 4:35 a.m. OK Java 21 TESTS 30 1374 262144000
344434033 Naamani H Oct. 18, 2025, 5:17 a.m. OK Java 8 TESTS 30 874 146841600
344433871 Naamani H Oct. 18, 2025, 5:16 a.m. OK Java 8 TESTS 30 874 146841600
344530301 0xM7md H Oct. 18, 2025, 4:01 p.m. OK PyPy 3-64 TESTS 30 421 82636800

remove filters

Back to search problems