Codeforces Round 1056 (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
2155 Codeforces Round 1056 (Div. 2) FINISHED False 7200 16723523 Oct. 5, 2025, 4:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 10177 ) C The Ancient Wizards' Capes PROGRAMMING brute force dp implementation

There are (n) wizards in a row numbered (1) to (n) from left to right. Each wizard has an invisibility cape which can be worn either on his left side or on his right side. Harry walks from the position of wizard (1) until the position of wizard (n) ((1 \le n \le 10^5)), and registers how many wizards he sees from each wizard's position. A wizard in position (j) is visible from position (i) if: Wizard (j) wears his cape on his left side and (i \ge j). Wizard (j) wears his cape on his right side and (i \le j). In particular, note that wizard (i) is visible from position (i). Harry's list is very old but, after much work, you managed to decipher it. The list is an array (a) of (n) elements, where the (i)-th element (a_i) ((1 \le a_i \le n)) is the number of wizards that Harry saw from the position of wizard (i). Your task is to determine how many of all the possible cape arrangements that Harry could have seen are consistent with the data recorded by the list, modulo (676\,767\,677). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains a single integer (n) ((1 \le n \le 10^5)) — the length of (a). The second line contains (n) integers (a_1, a_2, \ldots, a_n) ((1 \le a_i \le n)) — the elements of (a). It is guaranteed that the sum of (n) over all test cases does not exceed (10^5). For each test case, print one integer — the number of arrangements for the wizards' capes that satisfy the condition, modulo (676\,767\,677). The image below shows an arrangement of capes that matches Harry's list in the second test case. Wizard 1 has the invisibility cape on his left side, while wizards (2), (3), and (4) wear it on their right side. From position (1), we can see wizards $$$1$$

Tutorials

Codeforces Round 1056 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
342154765 aman220507 C Oct. 6, 2025, 4:28 a.m. OK C++17 (GCC 7-32) TESTS 15 61 0
342133198 newhackerxkcd C Oct. 5, 2025, 9:49 p.m. OK C++17 (GCC 7-32) TESTS 15 61 0
342106664 ssooraj2792000 C Oct. 5, 2025, 6:16 p.m. OK C++17 (GCC 7-32) TESTS 15 61 0
342107251 EAS.82 C Oct. 5, 2025, 6:17 p.m. OK C++17 (GCC 7-32) TESTS 15 61 512000
342134752 repmann C Oct. 5, 2025, 10:22 p.m. OK C++17 (GCC 7-32) TESTS 15 61 1331200
342162931 Just_Relax7 C Oct. 6, 2025, 5:57 a.m. OK C++17 (GCC 7-32) TESTS 15 62 0
342162004 Marsian_25 C Oct. 6, 2025, 5:48 a.m. OK C++17 (GCC 7-32) TESTS 15 62 0
342160479 -practicer- C Oct. 6, 2025, 5:33 a.m. OK C++17 (GCC 7-32) TESTS 15 62 0
342158027 redhunt C Oct. 6, 2025, 5:07 a.m. OK C++17 (GCC 7-32) TESTS 15 62 0
342157506 hamdymo_93 C Oct. 6, 2025, 5:02 a.m. OK C++17 (GCC 7-32) TESTS 15 62 0
342148670 Azhar11 C Oct. 6, 2025, 3:08 a.m. OK C++20 (GCC 13-64) TESTS 15 46 0
342142333 duke10 C Oct. 6, 2025, 1:34 a.m. OK C++20 (GCC 13-64) TESTS 15 46 0
342133682 Alvaro_Quispe C Oct. 5, 2025, 9:58 p.m. OK C++20 (GCC 13-64) TESTS 15 46 0
342135174 MiraculousN C Oct. 5, 2025, 10:31 p.m. OK C++20 (GCC 13-64) TESTS 15 46 3276800
342143932 jstzmxuan C Oct. 6, 2025, 2 a.m. OK C++20 (GCC 13-64) TESTS 15 46 4608000
342160233 jack061206 C Oct. 6, 2025, 5:31 a.m. OK C++20 (GCC 13-64) TESTS 15 61 0
342158480 Serendipity__ C Oct. 6, 2025, 5:12 a.m. OK C++20 (GCC 13-64) TESTS 15 61 0
342156230 Dominator039 C Oct. 6, 2025, 4:48 a.m. OK C++20 (GCC 13-64) TESTS 15 61 0
342151296 courtship C Oct. 6, 2025, 3:43 a.m. OK C++20 (GCC 13-64) TESTS 15 61 0
342147132 IneedHELPpls C Oct. 6, 2025, 2:48 a.m. OK C++20 (GCC 13-64) TESTS 15 61 0
342157914 duchuan75 C Oct. 6, 2025, 5:06 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 46 0
342152857 Firystal C Oct. 6, 2025, 4:03 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 46 0
342150538 yuyuan567 C Oct. 6, 2025, 3:33 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 46 0
342148560 chenjinghang123434 C Oct. 6, 2025, 3:07 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 46 0
342136813 Ganna_Gamal C Oct. 5, 2025, 11:16 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 46 0
342136797 Ganna_ C Oct. 5, 2025, 11:15 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 46 0
342128819 wh01sShakin C Oct. 5, 2025, 8:45 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 46 0
342128632 who1sShakin C Oct. 5, 2025, 8:44 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 46 0
342126015 Saurav5384 C Oct. 5, 2025, 8:19 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 46 0
342156996 wuyin331 C Oct. 6, 2025, 4:57 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 46 48128000
342129923 Brackets12 C Oct. 5, 2025, 8:57 p.m. OK FPC TESTS 15 62 5632000
342139301 ruban C Oct. 6, 2025, 12:33 a.m. OK FPC TESTS 15 77 38502400
342113271 bhslyv C Oct. 5, 2025, 6:28 p.m. OK GNU C11 TESTS 15 77 2355200
342115703 gustt_ C Oct. 5, 2025, 6:32 p.m. OK Go TESTS 15 108 1228800
342115762 keshav14 C Oct. 5, 2025, 6:32 p.m. OK Java 21 TESTS 15 249 409600
342159574 nikshaykataria3 C Oct. 6, 2025, 5:24 a.m. OK Java 21 TESTS 15 280 614400
342132925 RockingMat C Oct. 5, 2025, 9:43 p.m. OK Java 21 TESTS 15 280 716800
342155815 vineetiwari C Oct. 6, 2025, 4:42 a.m. OK Java 21 TESTS 15 280 1331200
342131967 WrongAnswerOnTestCase2 C Oct. 5, 2025, 9:27 p.m. OK Java 21 TESTS 15 280 3584000
342129327 vineetiwari C Oct. 5, 2025, 8:51 p.m. OK Java 21 TESTS 15 281 307200
342106243 chamankumar C Oct. 5, 2025, 6:15 p.m. OK Java 21 TESTS 15 296 307200
342158593 Saucyy C Oct. 6, 2025, 5:13 a.m. OK Java 21 TESTS 15 296 512000
342138204 lilac7597 C Oct. 6, 2025, 12:05 a.m. OK Java 21 TESTS 15 312 819200
342108975 JordanPoole C Oct. 5, 2025, 6:20 p.m. OK Java 21 TESTS 15 312 2560000
342132030 xmjlove C Oct. 5, 2025, 9:28 p.m. OK Java 8 TESTS 15 171 0
342116319 abhi_theq C Oct. 5, 2025, 6:33 p.m. OK Java 8 TESTS 15 202 0
342107972 testtest111ksjfrdvn C Oct. 5, 2025, 6:18 p.m. OK Java 8 TESTS 15 202 0
342150479 NithishReddyK C Oct. 6, 2025, 3:32 a.m. OK Java 8 TESTS 15 202 6348800
342117425 public-static-void-main C Oct. 5, 2025, 6:34 p.m. OK Java 8 TESTS 15 233 16998400
342107912 vasily.slesarev C Oct. 5, 2025, 6:18 p.m. OK Java 8 TESTS 15 312 0
342107038 _samsung_ C Oct. 5, 2025, 6:17 p.m. OK Java 8 TESTS 15 327 0
342128961 Akshatgupta069_069 C Oct. 5, 2025, 8:47 p.m. OK Java 8 TESTS 15 405 39014400
342155650 tuffknuckles C Oct. 6, 2025, 4:40 a.m. OK Node.js TESTS 15 218 9728000
342145493 bpdolson C Oct. 6, 2025, 2:24 a.m. OK PyPy 3 TESTS 15 234 9113600
342124692 John_cena030 C Oct. 5, 2025, 8:09 p.m. OK PyPy 3 TESTS 15 280 10444800
342111728 adityakudale2712 C Oct. 5, 2025, 6:25 p.m. OK PyPy 3 TESTS 15 312 10240000
342115174 Umka__15 C Oct. 5, 2025, 6:31 p.m. OK PyPy 3 TESTS 15 390 10649600
342107280 shuzeyfa C Oct. 5, 2025, 6:17 p.m. OK PyPy 3-64 TESTS 15 140 9932800
342141885 hxu10 C Oct. 6, 2025, 1:25 a.m. OK PyPy 3-64 TESTS 15 140 13107200
342158441 gardengnome C Oct. 6, 2025, 5:12 a.m. OK PyPy 3-64 TESTS 15 140 14233600
342160212 kamio-misuzu C Oct. 6, 2025, 5:31 a.m. OK PyPy 3-64 TESTS 15 140 14336000
342114059 sohamgupta.1515 C Oct. 5, 2025, 6:29 p.m. OK PyPy 3-64 TESTS 15 155 13004800
342112602 smilence C Oct. 5, 2025, 6:27 p.m. OK PyPy 3-64 TESTS 15 156 11878400
342105266 coderrg21 C Oct. 5, 2025, 6:13 p.m. OK PyPy 3-64 TESTS 15 171 12697600
342113608 idkwhynobrains C Oct. 5, 2025, 6:29 p.m. OK PyPy 3-64 TESTS 15 171 12902400
342124025 jvatsal0709 C Oct. 5, 2025, 8:04 p.m. OK PyPy 3-64 TESTS 15 171 13619200
342162503 Surajk21 C Oct. 6, 2025, 5:53 a.m. OK PyPy 3-64 TESTS 15 171 14336000
342111763 alexmurillosancho C Oct. 5, 2025, 6:25 p.m. OK Python 3 TESTS 15 108 11776000
342115961 koushcodes C Oct. 5, 2025, 6:33 p.m. OK Python 3 TESTS 15 109 11264000
342107479 pc__ra C Oct. 5, 2025, 6:17 p.m. OK Python 3 TESTS 15 124 11776000
342112876 fomo_demod_01 C Oct. 5, 2025, 6:27 p.m. OK Python 3 TESTS 15 139 11059200
342105803 Code6Sense C Oct. 5, 2025, 6:14 p.m. OK Python 3 TESTS 15 139 11776000
342128228 __RaFiQ__ C Oct. 5, 2025, 8:39 p.m. OK Python 3 TESTS 15 139 11980800
342124016 aaditya.samadhiya11 C Oct. 5, 2025, 8:04 p.m. OK Python 3 TESTS 15 140 11980800
342107810 999Wfan C Oct. 5, 2025, 6:18 p.m. OK Python 3 TESTS 15 140 11980800
342108367 wajbharath6312 C Oct. 5, 2025, 6:19 p.m. OK Python 3 TESTS 15 140 13926400
342114390 scholarc C Oct. 5, 2025, 6:30 p.m. OK Python 3 TESTS 15 155 13004800
342133050 nonrice C Oct. 5, 2025, 9:46 p.m. OK Rust 2024 TESTS 15 77 0

remove filters

Back to search problems