Codeforces Round 1047 (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
2137 Codeforces Round 1047 (Div. 3) FINISHED False 8100 19149923 Sept. 7, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 26314 ) B Fun Permutation PROGRAMMING constructive algorithms math number theory

You are given a permutation(^{\text{∗}}) (p) of size (n). Your task is to find a permutation (q) of size (n) such that (\operatorname{GCD})(^{\text{†}})((p_i+q_i, p_{i+1}+q_{i+1}) \geq 3) for all (1 \leq i<n). In other words, the greatest common divisor of the sum of any two adjacent positions should be at least (3). It can be shown that this is always possible. (^{\text{∗}})A permutation of length (m) is an array consisting of (m) distinct integers from (1) to (m) 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 ((m=3) but there is (4) in the array). (^{\text{†}})(\gcd(x, y)) denotes the greatest common divisor (GCD) of integers (x) and (y). 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 an integer (n) ((2 \leq n \leq 2\cdot 10^5)). The second line contains (n) integers (p_1,p_2,\ldots,p_n) ((1 \leq p_i \leq n)). It is guaranteed that the given array forms a permutation. It is guaranteed that the sum of (n) over all test cases does not exceed (2\cdot 10^5). For each test case, output the permutation (q) on a new line. If there are multiple possible answers, you may output any. In the first test case, (\operatorname{GCD}(1+2,3+3)=3\geq 3) and (\operatorname{GCD}(3+3,2+1)=3\geq3), so the output is correct.

Tutorials

Codeforces Round 1047 (Div. 3) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
337497780 shaker-500 B Sept. 8, 2025, 5:26 a.m. OK C# 13 TESTS 6 311 29081600
337464477 mahmudur9 B Sept. 7, 2025, 7:07 p.m. OK C# 13 TESTS 6 343 34816000
337498905 shaker-500 B Sept. 8, 2025, 5:41 a.m. OK C# 13 TESTS 6 374 30310400
337454089 prcsamrat B Sept. 7, 2025, 5:37 p.m. OK C++17 (GCC 7-32) TESTS 6 78 0
337475656 ahlidinrahmonov B Sept. 7, 2025, 9:45 p.m. OK C++17 (GCC 7-32) TESTS 6 78 102400
337497909 MYNOUL_HASAN2 B Sept. 8, 2025, 5:28 a.m. OK C++17 (GCC 7-32) TESTS 6 93 0
337497394 shribak B Sept. 8, 2025, 5:21 a.m. OK C++17 (GCC 7-32) TESTS 6 93 0
337496536 UG_BEAST B Sept. 8, 2025, 5:09 a.m. OK C++17 (GCC 7-32) TESTS 6 93 0
337496305 __New_coder B Sept. 8, 2025, 5:06 a.m. OK C++17 (GCC 7-32) TESTS 6 93 0
337495783 smurfg B Sept. 8, 2025, 4:59 a.m. OK C++17 (GCC 7-32) TESTS 6 93 0
337494265 Ibrahemahmed23 B Sept. 8, 2025, 4:34 a.m. OK C++17 (GCC 7-32) TESTS 6 93 0
337493343 lazyKoala123 B Sept. 8, 2025, 4:17 a.m. OK C++17 (GCC 7-32) TESTS 6 93 0
337492376 AyushPallod B Sept. 8, 2025, 3:58 a.m. OK C++17 (GCC 7-32) TESTS 6 93 0
337500733 aayushsaxena17 B Sept. 8, 2025, 6:05 a.m. OK C++20 (GCC 13-64) TESTS 6 77 0
337498549 miyan1221 B Sept. 8, 2025, 5:36 a.m. OK C++20 (GCC 13-64) TESTS 6 77 0
337497954 Hksingh B Sept. 8, 2025, 5:28 a.m. OK C++20 (GCC 13-64) TESTS 6 77 0
337496908 djsksbrbf B Sept. 8, 2025, 5:15 a.m. OK C++20 (GCC 13-64) TESTS 6 77 0
337496294 Vic710 B Sept. 8, 2025, 5:06 a.m. OK C++20 (GCC 13-64) TESTS 6 77 0
337493720 thebold497 B Sept. 8, 2025, 4:25 a.m. OK C++20 (GCC 13-64) TESTS 6 77 0
337492572 accord B Sept. 8, 2025, 4:02 a.m. OK C++20 (GCC 13-64) TESTS 6 77 0
337487769 Panyang B Sept. 8, 2025, 2:45 a.m. OK C++20 (GCC 13-64) TESTS 6 77 0
337487684 non_fried_chips B Sept. 8, 2025, 2:44 a.m. OK C++20 (GCC 13-64) TESTS 6 77 0
337487021 Z.I.A.D B Sept. 8, 2025, 2:34 a.m. OK C++20 (GCC 13-64) TESTS 6 77 0
337447348 bluish B Sept. 7, 2025, 4:57 p.m. OK C++23 (GCC 14-64, msys2) TESTS 6 46 204800
337460096 Shahriar_Imran B Sept. 7, 2025, 6:23 p.m. OK C++23 (GCC 14-64, msys2) TESTS 6 61 0
337497632 maspy B Sept. 8, 2025, 5:24 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 61 204800
337500301 pstu-Sadman B Sept. 8, 2025, 5:59 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 77 0
337499205 Bruce_wayne24 B Sept. 8, 2025, 5:45 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 77 0
337497930 RuinGuard B Sept. 8, 2025, 5:28 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 77 0
337497200 deadmonster B Sept. 8, 2025, 5:19 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 77 0
337497184 PrimeHunter B Sept. 8, 2025, 5:18 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 77 0
337496766 garora22 B Sept. 8, 2025, 5:13 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 77 0
337495584 lovesharma7 B Sept. 8, 2025, 4:56 a.m. OK C++23 (GCC 14-64, msys2) TESTS 6 77 0
337457134 AntonKorch B Sept. 7, 2025, 5:58 p.m. OK F# 9 TESTS 6 140 36454400
337496475 AntonKorch B Sept. 8, 2025, 5:09 a.m. OK F# 9 TESTS 6 140 37273600
337456784 AntonKorch B Sept. 7, 2025, 5:55 p.m. OK F# 9 TESTS 6 140 37376000
337498096 AntonKorch B Sept. 8, 2025, 5:30 a.m. OK F# 9 TESTS 6 156 39833600
337454456 AntonKorch B Sept. 7, 2025, 5:39 p.m. OK F# 9 TESTS 6 171 30412800
337453438 AntonKorch B Sept. 7, 2025, 5:32 p.m. OK F# 9 TESTS 6 171 36044800
337455957 AntonKorch B Sept. 7, 2025, 5:49 p.m. OK F# 9 TESTS 6 187 36044800
337496266 AntonKorch B Sept. 8, 2025, 5:06 a.m. OK F# 9 TESTS 6 187 37376000
337496136 AntonKorch B Sept. 8, 2025, 5:04 a.m. OK F# 9 TESTS 6 234 63692800
337453954 AntonKorch B Sept. 7, 2025, 5:36 p.m. OK F# 9 TESTS 6 249 33280000
337458803 niskarshmnnit B Sept. 7, 2025, 6:11 p.m. OK GNU C11 TESTS 6 843 1638400
337468541 2405122_Rajdip_Deb B Sept. 7, 2025, 7:54 p.m. OK GNU C11 TESTS 6 858 819200
337498854 ShashiS B Sept. 8, 2025, 5:41 a.m. OK GNU C11 TESTS 6 874 102400
337465875 Md_Al_Amin20041108 B Sept. 7, 2025, 7:22 p.m. OK GNU C11 TESTS 6 874 1740800
337478108 me_shivendra01 B Sept. 7, 2025, 10:43 p.m. OK Java 21 TESTS 6 265 2048000
337459213 joshisparsh18 B Sept. 7, 2025, 6:15 p.m. OK Java 21 TESTS 6 296 1024000
337494704 tekka_ity B Sept. 8, 2025, 4:42 a.m. OK Java 21 TESTS 6 296 1433600
337470141 arnavchhabra2005 B Sept. 7, 2025, 8:11 p.m. OK Java 21 TESTS 6 312 10035200
337488800 WrongAnswerOnTestCase2 B Sept. 8, 2025, 3:01 a.m. OK Java 21 TESTS 6 327 921600
337486928 duongtnhat B Sept. 8, 2025, 2:32 a.m. OK Java 21 TESTS 6 327 921600
337476704 BOB_005 B Sept. 7, 2025, 10:05 p.m. OK Java 21 TESTS 6 358 512000
337449215 priyaroy3370 B Sept. 7, 2025, 5:06 p.m. OK Java 21 TESTS 6 406 819200
337453532 rakshitsingh333 B Sept. 7, 2025, 5:33 p.m. OK Java 21 TESTS 6 437 819200
337464291 akshat.codes B Sept. 7, 2025, 7:04 p.m. OK Java 21 TESTS 6 499 24371200
337465061 Ashu2030 B Sept. 7, 2025, 7:13 p.m. OK Java 8 TESTS 6 186 0
337462302 suntansoker B Sept. 7, 2025, 6:43 p.m. OK Java 8 TESTS 6 218 2662400
337448163 T-error B Sept. 7, 2025, 5:01 p.m. OK Java 8 TESTS 6 218 3584000
337446390 Eslam_Ahmed B Sept. 7, 2025, 4:53 p.m. OK Java 8 TESTS 6 233 2662400
337492828 jhemanth B Sept. 8, 2025, 4:07 a.m. OK Java 8 TESTS 6 655 0
337466094 Yaser2004 B Sept. 7, 2025, 7:25 p.m. OK Java 8 TESTS 6 656 0
337455198 userlowlevel B Sept. 7, 2025, 5:44 p.m. OK Java 8 TESTS 6 687 0
337449197 not_mohith B Sept. 7, 2025, 5:06 p.m. OK Java 8 TESTS 6 702 0
337456144 adsulswapnil27 B Sept. 7, 2025, 5:51 p.m. OK Java 8 TESTS 6 734 0
337451093 ..pk B Sept. 7, 2025, 5:17 p.m. OK Java 8 TESTS 6 749 0
337486009 aolive505 B Sept. 8, 2025, 2:13 a.m. OK JavaScript TESTS 6 202 28262400
337460618 QuadD4rv1n7 B Sept. 7, 2025, 6:27 p.m. OK Kotlin 2.2 TESTS 6 217 5324800
337486465 swseverance B Sept. 8, 2025, 2:23 a.m. OK Node.js TESTS 6 296 64102400
337445795 gopikrishna9968 B Sept. 7, 2025, 4:51 p.m. OK PyPy 3 TESTS 6 389 18227200
337477929 Saicoder89 B Sept. 7, 2025, 10:38 p.m. OK PyPy 3 TESTS 6 406 17100800
337455336 sidskull103 B Sept. 7, 2025, 5:45 p.m. OK PyPy 3 TESTS 6 468 17100800
337465070 mawo78 B Sept. 7, 2025, 7:13 p.m. OK PyPy 3-64 TESTS 6 124 21708800
337468790 hugoback01 B Sept. 7, 2025, 7:57 p.m. OK PyPy 3-64 TESTS 6 139 23961600
337468759 niyazi B Sept. 7, 2025, 7:57 p.m. OK PyPy 3-64 TESTS 6 155 19456000
337453028 gardengnome B Sept. 7, 2025, 5:29 p.m. OK PyPy 3-64 TESTS 6 155 22016000
337474682 Ritwin B Sept. 7, 2025, 9:25 p.m. OK PyPy 3-64 TESTS 6 156 19046400
337460289 bhuvan_sankar_gupta B Sept. 7, 2025, 6:24 p.m. OK PyPy 3-64 TESTS 6 156 19456000
337481330 jvatsal0709 B Sept. 8, 2025, 12:20 a.m. OK PyPy 3-64 TESTS 6 156 28467200
337482199 ntarsis30 B Sept. 8, 2025, 12:43 a.m. OK PyPy 3-64 TESTS 6 171 16998400
337477286 SerbanC B Sept. 7, 2025, 10:20 p.m. OK PyPy 3-64 TESTS 6 171 19456000
337484835 Baichuan B Sept. 8, 2025, 1:47 a.m. OK PyPy 3-64 TESTS 6 171 21196800
337493052 pramitkchandra10 B Sept. 8, 2025, 4:12 a.m. OK Python 3 TESTS 6 171 31334400
337453940 Gautam_kharkwal B Sept. 7, 2025, 5:36 p.m. OK Python 3 TESTS 6 171 31334400
337449598 Bantu1919 B Sept. 7, 2025, 5:08 p.m. OK Python 3 TESTS 6 171 31436800
337464090 BWHM B Sept. 7, 2025, 7:02 p.m. OK Python 3 TESTS 6 187 29491200
337446938 rejebmohamed62 B Sept. 7, 2025, 4:55 p.m. OK Python 3 TESTS 6 203 28672000
337450975 arpit_yadav6155 B Sept. 7, 2025, 5:16 p.m. OK Python 3 TESTS 6 250 40652800
337469860 ne_egorova B Sept. 7, 2025, 8:07 p.m. OK Python 3 TESTS 6 265 22528000
337484782 prime_255 B Sept. 8, 2025, 1:46 a.m. OK Python 3 TESTS 6 265 23347200
337483934 trustNobody B Sept. 8, 2025, 1:26 a.m. OK Python 3 TESTS 6 281 20889600
337460329 ayush_gsv23 B Sept. 7, 2025, 6:25 p.m. OK Python 3 TESTS 6 281 22425600
337475039 Ritwin B Sept. 7, 2025, 9:32 p.m. OK Ruby 3 TESTS 6 984 49254400
337479153 lyteabovenyte B Sept. 7, 2025, 11:14 p.m. OK Rust 2021 TESTS 6 124 10752000
337474093 mindflux B Sept. 7, 2025, 9:13 p.m. OK Rust 2024 TESTS 6 77 819200
337489856 pohzipohzi B Sept. 8, 2025, 3:17 a.m. OK Rust 2024 TESTS 6 77 2355200
337482759 0x81 B Sept. 8, 2025, 12:56 a.m. OK Rust 2024 TESTS 6 124 2867200

remove filters

Back to search problems