Codeforces Round 1022 (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
2108 Codeforces Round 1022 (Div. 2) FINISHED False 7200 30295523 May 1, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 22088 ) A Permutation Warm-Up PROGRAMMING combinatorics greedy math number theory

For a permutation (p) of length (n)(^{\text{∗}}), we define the function: () f(p) = \sum_{i=1}^{n} \lvert p_i - i \rvert () You are given a number (n). You need to compute how many distinct values the function (f(p)) can take when considering all possible permutations of the numbers from (1) to (n). (^{\text{∗}})A permutation of length (n) 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). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 100)). The description of the test cases follows. The first line of each test case contains an integer (n) ((1 \leq n \leq 500)) — the number of numbers in the permutations. For each test case, output a single integer — the number of distinct values of the function (f(p)) for the given length of permutations. Consider the first two examples of the input. For (n = 2), there are only (2) permutations — (1, 2) and (2, 1). (f(1, 2) = \lvert 1 - 1 \rvert + \lvert 2 - 2 \rvert = 0), (f(2, 1) = \lvert 2 - 1 \rvert + \lvert 1 - 2 \rvert = 1 + 1 = 2). Thus, the function takes (2) distinct values. For (n=3), there are already (6) permutations: (1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1), the function values of which will be (0, 2, 2, 4, 4), and (4) respectively, meaning there are a total of (3) values.

Tutorials

Codeforces Round 1022 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
318067432 piyushpathak3004 A May 2, 2025, 5:51 a.m. OK C++17 (GCC 7-32) TESTS 4 30 0
318062457 hpesoj A May 2, 2025, 4:47 a.m. OK C++17 (GCC 7-32) TESTS 4 30 0
318045902 kingfisher-2 A May 1, 2025, 10:33 p.m. OK C++17 (GCC 7-32) TESTS 4 30 0
318040692 jk_neu A May 1, 2025, 8:45 p.m. OK C++17 (GCC 7-32) TESTS 4 30 0
318040496 Muhimin A May 1, 2025, 8:42 p.m. OK C++17 (GCC 7-32) TESTS 4 30 0
318030695 sjmahmud21 A May 1, 2025, 6:38 p.m. OK C++17 (GCC 7-32) TESTS 4 30 0
318030647 Tanzil-Hasan-Jishan02 A May 1, 2025, 6:37 p.m. OK C++17 (GCC 7-32) TESTS 4 30 0
318029744 Anshi_23 A May 1, 2025, 6:28 p.m. OK C++17 (GCC 7-32) TESTS 4 30 0
318025211 fahimulkadir129 A May 1, 2025, 5:49 p.m. OK C++17 (GCC 7-32) TESTS 4 30 0
318021920 uhtred A May 1, 2025, 5:26 p.m. OK C++17 (GCC 7-32) TESTS 4 30 0
318064320 bluddyFang A May 2, 2025, 5:14 a.m. OK C++20 (GCC 13-64) TESTS 4 30 0
318056020 Roberth_G A May 2, 2025, 2:57 a.m. OK C++20 (GCC 13-64) TESTS 4 30 0
318053478 ZX1123 A May 2, 2025, 2:08 a.m. OK C++20 (GCC 13-64) TESTS 4 30 0
318037341 codeRGB A May 1, 2025, 7:55 p.m. OK C++20 (GCC 13-64) TESTS 4 30 0
318032461 Ramisa_Raidah A May 1, 2025, 6:55 p.m. OK C++20 (GCC 13-64) TESTS 4 30 0
318024392 zapi06 A May 1, 2025, 5:43 p.m. OK C++20 (GCC 13-64) TESTS 4 30 0
318018212 Toronto.Tokyo A May 1, 2025, 5:04 p.m. OK C++20 (GCC 13-64) TESTS 4 30 0
318012273 coder_0_4 A May 1, 2025, 4:29 p.m. OK C++20 (GCC 13-64) TESTS 4 30 0
318030644 Andrewhazem A May 1, 2025, 6:37 p.m. OK C++20 (GCC 13-64) TESTS 4 30 102400
318026408 Szzzp A May 1, 2025, 5:59 p.m. OK C++20 (GCC 13-64) TESTS 4 30 102400
318065612 eatingeating A May 2, 2025, 5:30 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 30 0
318060425 LHaooo A May 2, 2025, 4:12 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 30 0
318057309 Rakib731 A May 2, 2025, 3:18 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 30 0
318056668 hi_its_matthew A May 2, 2025, 3:09 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 30 0
318055484 link1k A May 2, 2025, 2:47 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 30 0
318055405 Wustking A May 2, 2025, 2:46 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 30 0
318049043 xiaowang524 A May 2, 2025, 12:05 a.m. OK C++23 (GCC 14-64, msys2) TESTS 4 30 0
318042955 Razzle A May 1, 2025, 9:26 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 30 0
318040128 Putin_er_Abbu A May 1, 2025, 8:36 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 30 0
318039526 bera_474 A May 1, 2025, 8:28 p.m. OK C++23 (GCC 14-64, msys2) TESTS 4 30 0
318059726 Ahmetyaz A May 2, 2025, 4 a.m. OK FPC TESTS 4 31 0
318023258 Niarj_10 A May 1, 2025, 5:35 p.m. OK GNU C11 TESTS 4 30 0
318041206 Itsmylove1 A May 1, 2025, 8:53 p.m. OK GNU C11 TESTS 4 46 102400
318030391 wazid03 A May 1, 2025, 6:35 p.m. OK GNU C11 TESTS 4 46 102400
318021789 aishanbhagat A May 1, 2025, 5:25 p.m. OK GNU C11 TESTS 4 46 102400
318015065 Cessdav A May 1, 2025, 4:34 p.m. OK GNU C11 TESTS 4 61 0
318030743 Divya0612_ A May 1, 2025, 6:38 p.m. OK GNU C11 TESTS 4 62 102400
318060095 tahsin_ferdous A May 2, 2025, 4:06 a.m. OK Go TESTS 4 46 0
318024141 YhuanDebeste A May 1, 2025, 5:41 p.m. OK Haskell TESTS 4 62 0
318020306 Gitansh_shekhar A May 1, 2025, 5:16 p.m. OK Java 21 TESTS 4 186 307200
318026047 Yootoo A May 1, 2025, 5:56 p.m. OK Java 21 TESTS 4 202 0
318037059 jerdno A May 1, 2025, 7:51 p.m. OK Java 21 TESTS 4 202 204800
318061745 Dg10 A May 2, 2025, 4:35 a.m. OK Java 21 TESTS 4 202 307200
318060749 rajasomeshwar_bitla A May 2, 2025, 4:18 a.m. OK Java 21 TESTS 4 202 1638400
318065975 AKhacks A May 2, 2025, 5:34 a.m. OK Java 21 TESTS 4 203 409600
318068129 vishnuyash A May 2, 2025, 5:58 a.m. OK Java 21 TESTS 4 233 307200
318040229 ashwanisingh240536 A May 1, 2025, 8:38 p.m. OK Java 21 TESTS 4 233 614400
318042174 noobie_ticku A May 1, 2025, 9:10 p.m. OK Java 21 TESTS 4 233 716800
318020788 Eslam_Ahmed A May 1, 2025, 5:19 p.m. OK Java 21 TESTS 4 234 409600
318026314 Shashwata_32 A May 1, 2025, 5:58 p.m. OK Java 8 TESTS 4 124 0
318066778 Purav_Shah07 A May 2, 2025, 5:44 a.m. OK Java 8 TESTS 4 139 0
318060338 Dduo A May 2, 2025, 4:10 a.m. OK Java 8 TESTS 4 139 0
318067469 Kaikondar A May 2, 2025, 5:52 a.m. OK Java 8 TESTS 4 140 0
318052107 hiddenhopes A May 2, 2025, 1:38 a.m. OK Java 8 TESTS 4 140 0
318032128 adibhai0845R A May 1, 2025, 6:52 p.m. OK Java 8 TESTS 4 140 0
318052363 kunal021 A May 2, 2025, 1:43 a.m. OK Java 8 TESTS 4 155 0
318022460 rohitashwant45 A May 1, 2025, 5:29 p.m. OK Java 8 TESTS 4 155 0
318025689 Pranav_45 A May 1, 2025, 5:53 p.m. OK Java 8 TESTS 4 156 0
318012460 saikrishnamohan A May 1, 2025, 4:29 p.m. OK Java 8 TESTS 4 156 0
318021623 TarTarus1 A May 1, 2025, 5:24 p.m. OK Perl TESTS 4 61 0
318018902 YhuanDebeste A May 1, 2025, 5:09 p.m. OK Perl TESTS 4 61 0
318018671 YhuanDebeste A May 1, 2025, 5:08 p.m. OK Perl TESTS 4 62 0
318019843 gr_priyk A May 1, 2025, 5:14 p.m. OK PyPy 3 TESTS 4 78 0
318064100 Toinfinity A May 2, 2025, 5:11 a.m. OK PyPy 3 TESTS 4 78 204800
318060636 Hastorius A May 2, 2025, 4:16 a.m. OK PyPy 3 TESTS 4 78 204800
318032124 Akiii_2023 A May 1, 2025, 6:52 p.m. OK PyPy 3 TESTS 4 78 204800
318024944 Potato002 A May 1, 2025, 5:47 p.m. OK PyPy 3 TESTS 4 92 1638400
318033853 Pabloo-04 A May 1, 2025, 7:11 p.m. OK PyPy 3 TESTS 4 93 204800
318060321 Akash_123 A May 2, 2025, 4:10 a.m. OK PyPy 3 TESTS 4 108 204800
318019541 Srivissy A May 1, 2025, 5:12 p.m. OK PyPy 3 TESTS 4 108 1228800
318054882 WAan A May 2, 2025, 2:36 a.m. OK PyPy 3-64 TESTS 4 62 204800
318044604 aAshish_02 A May 1, 2025, 9:58 p.m. OK PyPy 3-64 TESTS 4 62 204800
318050168 gardengnome A May 2, 2025, 12:45 a.m. OK PyPy 3-64 TESTS 4 62 1331200
318055886 kelzzin2_fan A May 2, 2025, 2:54 a.m. OK PyPy 3-64 TESTS 4 77 0
318022150 alexwice A May 1, 2025, 5:27 p.m. OK PyPy 3-64 TESTS 4 77 0
318020585 sifatulla A May 1, 2025, 5:18 p.m. OK PyPy 3-64 TESTS 4 77 0
318017721 gurjot008 A May 1, 2025, 5:02 p.m. OK PyPy 3-64 TESTS 4 77 0
318065680 Beaten A May 2, 2025, 5:31 a.m. OK PyPy 3-64 TESTS 4 77 204800
318039327 yarathealmighty A May 1, 2025, 8:24 p.m. OK PyPy 3-64 TESTS 4 77 204800
318033825 MarkVerk A May 1, 2025, 7:11 p.m. OK PyPy 3-64 TESTS 4 77 204800
318022704 anthorstar A May 1, 2025, 5:31 p.m. OK Python 2 TESTS 4 77 0
318018207 YhuanDebeste A May 1, 2025, 5:04 p.m. OK Python 2 TESTS 4 77 0
318048918 OLOGY A May 2, 2025, 12:01 a.m. OK Python 3 TESTS 4 46 204800
318055705 bsdsf22a025 A May 2, 2025, 2:51 a.m. OK Python 3 TESTS 4 61 0
318041744 ruhittanvir14 A May 1, 2025, 9:03 p.m. OK Python 3 TESTS 4 61 204800
318026217 b23cm1038 A May 1, 2025, 5:57 p.m. OK Python 3 TESTS 4 61 204800
318024508 Fico7 A May 1, 2025, 5:44 p.m. OK Python 3 TESTS 4 61 204800
318050451 ShifaulHasan A May 2, 2025, 12:54 a.m. OK Python 3 TESTS 4 62 0
318040505 Vladimir001 A May 1, 2025, 8:42 p.m. OK Python 3 TESTS 4 62 0
318032608 fha22 A May 1, 2025, 6:57 p.m. OK Python 3 TESTS 4 62 0
318021137 Akshay_2006 A May 1, 2025, 5:21 p.m. OK Python 3 TESTS 4 62 0
318010198 prashillamichhane123 A May 1, 2025, 4:25 p.m. OK Python 3 TESTS 4 62 0
318018307 YhuanDebeste A May 1, 2025, 5:04 p.m. OK Ruby 3 TESTS 4 296 102400
318038063 Antumbra01 A May 1, 2025, 8:06 p.m. OK Rust 2021 TESTS 4 31 0
318049159 cinkozzz A May 2, 2025, 12:09 a.m. OK Rust 2021 TESTS 4 46 0
318053812 silicalet A May 2, 2025, 2:15 a.m. OK Rust 2021 TESTS 4 61 102400
318035951 Antumbra01 A May 1, 2025, 7:37 p.m. OK Rust 2021 TESTS 4 62 0

remove filters

Back to search problems