Pinely Round 1 (Div. 1 + Div. 2)

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
1761 Pinely Round 1 (Div. 1 + Div. 2) FINISHED False 9000 68311463 Nov. 20, 2022, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 212 ) F1 Anti-median (Easy Version) PROGRAMMING dp math

B"This is the easy version of the problem. The only difference between the two versions is the constraint on n . You can make hacks only if all versions of the problem are solved. Let's call an array a of odd length 2m+1 (with m ge 1 ) bad, if element a_{m+1} is equal to the median of this array. In other words, the array is bad if, after sorting it, the element at m+1 -st position remains the same. Let's call a permutation p of integers from 1 to n anti-median, if every its subarray of odd length ge 3 is not bad. You are already given values of some elements of the permutation. Find the number of ways to set unknown values to obtain an anti-median permutation. As this number can be very large, find it modulo 10^9+7 . The first line contains a single integer t ( 1 <= t <= 10^4 ) -- the number of test cases. The description of test cases follows. The first line of each test case contains a single integer n (2 <= n <= 1000) -- the length of the permutation. The second line of each test case contains n integers p_1, p_2, ldots, p_n ( 1 <= p_i <= n , or p_i = -1 ) -- the elements of the permutation. If p_i neq -1 , it's given, else it's unknown. It's guaranteed that if for some i neq j holds p_i neq -1, p_j neq -1 , then p_i neq p_j . It is guaranteed that the sum of n^2 over all test cases does not exceed 10^6 . For each test case, output a single integer -- the number of ways to set unknown values to obtain an anti-median permutation, modulo 10^9+7 . In the first test case, both [1, 2] and [2, 1] are anti-median. In the second test case, permutations [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2] are anti-median. The remaining two permutations, [1, 2, 3] , [3, 2, 1] , are bad arrays on their own, as their median, 2 , is in their middle. In the third test case, [1,"...

Tutorials

Pinely Round 1 (Div. 1 + Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
181792193 inaFSTream F1 Nov. 20, 2022, 4:22 p.m. OK GNU C++14 TESTS 84 46 4403200
181810467 liympanda F1 Nov. 20, 2022, 6:31 p.m. OK GNU C++14 TESTS 84 46 9830400
181810961 dmenezes F1 Nov. 20, 2022, 6:36 p.m. OK GNU C++14 TESTS 84 77 8908800
181796549 ugly2333 F1 Nov. 20, 2022, 4:41 p.m. OK GNU C++17 TESTS 84 62 102400
181792466 gisp_zjz F1 Nov. 20, 2022, 4:23 p.m. OK GNU C++17 TESTS 84 62 4096000
181787826 fivedemands F1 Nov. 20, 2022, 4:04 p.m. OK GNU C++17 TESTS 84 62 8089600
181809831 Tanvir71 F1 Nov. 20, 2022, 6:25 p.m. OK GNU C++17 (64) TESTS 84 46 102400
181797286 hitonanode F1 Nov. 20, 2022, 4:45 p.m. OK GNU C++17 (64) TESTS 84 46 102400
181837654 Akramzhan-K-007-25 F1 Nov. 21, 2022, 3:41 a.m. OK GNU C++17 (64) TESTS 84 62 4608000
181807817 Benq F1 Nov. 20, 2022, 6:07 p.m. OK GNU C++17 (64) TESTS 84 78 204800
181805382 _su1sen F1 Nov. 20, 2022, 5:51 p.m. OK GNU C++17 (64) TESTS 84 93 29593600
181793725 Benq F1 Nov. 20, 2022, 4:28 p.m. OK GNU C++17 (64) TESTS 84 498 64307200
181795481 ecnerwala F1 Nov. 20, 2022, 4:36 p.m. OK GNU C++20 (64) TESTS 84 46 0
181805577 ecnerwala F1 Nov. 20, 2022, 5:51 p.m. OK GNU C++20 (64) TESTS 84 46 102400
181797538 _menhera F1 Nov. 20, 2022, 4:46 p.m. OK GNU C++20 (64) TESTS 84 46 204800
181789408 mnbvmar F1 Nov. 20, 2022, 4:10 p.m. OK GNU C++20 (64) TESTS 84 46 4812800
181799120 BurnedChicken F1 Nov. 20, 2022, 4:53 p.m. OK GNU C++20 (64) TESTS 84 46 9216000
181795934 fallleaves07 F1 Nov. 20, 2022, 4:38 p.m. OK GNU C++20 (64) TESTS 84 62 8704000
181805368 ArchUser84 F1 Nov. 20, 2022, 5:50 p.m. OK GNU C++20 (64) TESTS 84 77 8396800
181805495 Golovanov399 F1 Nov. 20, 2022, 5:51 p.m. OK GNU C++20 (64) TESTS 84 93 16793600
181798951 noimi F1 Nov. 20, 2022, 4:52 p.m. OK GNU C++20 (64) TESTS 84 93 17100800
181796851 maroonrk F1 Nov. 20, 2022, 4:42 p.m. OK GNU C++20 (64) TESTS 84 108 46899200
181801616 gnomina007 F1 Nov. 20, 2022, 5:03 p.m. OK MS C++ 2017 TESTS 84 140 20480000

remove filters

Back to search problems