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 |
---|---|---|---|---|---|---|
1685 | Codeforces Round 794 (Div. 1) | FINISHED | False | 8100 | 83766263 | May 25, 2022, 5:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 452 ) | D1 | Permutation Weight (Easy Version) | PROGRAMMING | constructive algorithms dfs and similar ds | 2800 |
B"This is an easy version of the problem. The difference between the easy and hard versions is that in this version, you can output any permutation with the smallest weight. You are given a permutation p_1, p_2, ldots, p_n of integers from 1 to n . Let's define the weight of the permutation q_1, q_2, ldots, q_n of integers from 1 to n as |q_1 - p_{q_{2}}| + |q_2 - p_{q_{3}}| + ldots + |q_{n-1} - p_{q_{n}}| + |q_n - p_{q_{1}}| You want your permutation to be as lightweight as possible. Find any permutation q with the smallest possible weight. The first line of the input contains a single integer t ( 1 <= t <= 100 ) -- the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer n ( 2 <= n <= 200 ) -- the size of the permutation. The second line of each test case contains n integers p_1, p_2, ldots, p_n ( 1 <= p_i <= n , all p_i are distinct) -- the elements of the permutation. The sum of n over all test cases doesn't exceed 400 . For each test case, output n integers q_1, q_2, ldots, q_n ( 1 <= q_i <= n , all q_i are distinct) -- one of the permutations with the smallest weight. In the first test case, there are two permutations of length 2 : (1, 2) and (2, 1) . Permutation (1, 2) has weight |1 - p_2| + |2 - p_1| = 0 , and permutation (2, 1) has the same weight: |2 - p_1| + |1 - p_2| = 0 . You can output any of these permutations in this version. In the second test case, the weight of the permutation (1, 3, 4, 2) is |1 - p_3| + |3 - p_4| + |4 - p_2| + |2 - p_1| = |1 - 1| + |3 - 4| + |4 - 3| + |2 - 2| = 2 . There are no permutations with smaller weights. In the third test case, the weight of the permutation (1, 4, 2, 3, 5) is |1 - p_4| + |4 - p_2| + |2 - p_3| + |3 - p_5| + |5 - p_1| = |1"... |
103198 |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
158448062 | hos.lyric | D1 | May 25, 2022, 6:34 p.m. | OK | D | TESTS | 16 | 15 | 0 | 2800 | |
158479971 | L7-56 | D1 | May 26, 2022, 12:58 a.m. | OK | GNU C++14 | TESTS | 16 | 0 | 0 | 2800 | |
158497134 | LZDQ | D1 | May 26, 2022, 6:31 a.m. | OK | GNU C++14 | TESTS | 16 | 15 | 0 | 2800 | |
158487181 | themoon | D1 | May 26, 2022, 3:55 a.m. | OK | GNU C++14 | TESTS | 16 | 15 | 0 | 2800 | |
158462208 | dlalswp25 | D1 | May 25, 2022, 7:24 p.m. | OK | GNU C++14 | TESTS | 16 | 15 | 0 | 2800 | |
158510283 | AwakeAnay | D1 | May 26, 2022, 9:21 a.m. | OK | GNU C++14 | TESTS | 16 | 15 | 102400 | 2800 | |
158484321 | Drice | D1 | May 26, 2022, 2:58 a.m. | OK | GNU C++14 | TESTS | 16 | 15 | 102400 | 2800 | |
158510221 | AwakeAnay | D1 | May 26, 2022, 9:21 a.m. | OK | GNU C++14 | TESTS | 16 | 15 | 204800 | 2800 | |
158507475 | AwakeAnay | D1 | May 26, 2022, 8:44 a.m. | OK | GNU C++14 | TESTS | 16 | 15 | 204800 | 2800 | |
158502166 | feecIe6418 | D1 | May 26, 2022, 7:36 a.m. | OK | GNU C++14 | TESTS | 16 | 15 | 204800 | 2800 | |
158472987 | Potassium | D1 | May 25, 2022, 9:06 p.m. | OK | GNU C++14 | TESTS | 16 | 15 | 204800 | 2800 | |
158546068 | DeadlyPillow | D1 | May 26, 2022, 3:53 p.m. | OK | GNU C++17 | TESTS | 16 | 0 | 102400 | 2800 | |
158537489 | Aging1986 | D1 | May 26, 2022, 2:28 p.m. | OK | GNU C++17 | TESTS | 16 | 0 | 204800 | 2800 | |
158478220 | Radewoosh | D1 | May 25, 2022, 11:52 p.m. | OK | GNU C++17 | TESTS | 16 | 0 | 204800 | 2800 | |
158471187 | Kaibad | D1 | May 25, 2022, 8:36 p.m. | OK | GNU C++17 | TESTS | 16 | 15 | 0 | 2800 | |
158465713 | dranjohn | D1 | May 25, 2022, 7:41 p.m. | OK | GNU C++17 | TESTS | 16 | 15 | 0 | 2800 | |
158461017 | misaka18931 | D1 | May 25, 2022, 7:19 p.m. | OK | GNU C++17 | TESTS | 16 | 15 | 0 | 2800 | |
158460397 | YeongTree | D1 | May 25, 2022, 7:17 p.m. | OK | GNU C++17 | TESTS | 16 | 15 | 0 | 2800 | |
158456874 | tapir1729 | D1 | May 25, 2022, 7:02 p.m. | OK | GNU C++17 | TESTS | 16 | 15 | 0 | 2800 | |
158456702 | peti1234 | D1 | May 25, 2022, 7:02 p.m. | OK | GNU C++17 | TESTS | 16 | 15 | 0 | 2800 | |
158450485 | LJC00118 | D1 | May 25, 2022, 6:41 p.m. | OK | GNU C++17 | TESTS | 16 | 15 | 0 | 2800 | |
158499363 | enslaved | D1 | May 26, 2022, 6:59 a.m. | OK | GNU C++17 (64) | TESTS | 16 | 0 | 0 | 2800 | |
158459950 | Merkurev | D1 | May 25, 2022, 7:15 p.m. | OK | GNU C++17 (64) | TESTS | 16 | 0 | 0 | 2800 | |
158457463 | Nyaan | D1 | May 25, 2022, 7:05 p.m. | OK | GNU C++17 (64) | TESTS | 16 | 0 | 0 | 2800 | |
158581390 | errorgorn | D1 | May 27, 2022, 5:17 a.m. | OK | GNU C++17 (64) | TESTS | 16 | 15 | 0 | 2800 | |
158578450 | wygzgyw | D1 | May 27, 2022, 4:11 a.m. | OK | GNU C++17 (64) | TESTS | 16 | 15 | 0 | 2800 | |
158564464 | BERNARB.01 | D1 | May 26, 2022, 8:18 p.m. | OK | GNU C++17 (64) | TESTS | 16 | 15 | 0 | 2800 | |
158526612 | SevenDawns | D1 | May 26, 2022, 12:32 p.m. | OK | GNU C++17 (64) | TESTS | 16 | 15 | 0 | 2800 | |
158523027 | Intercept | D1 | May 26, 2022, 11:52 a.m. | OK | GNU C++17 (64) | TESTS | 16 | 15 | 0 | 2800 | |
158511975 | anonymous_777 | D1 | May 26, 2022, 9:43 a.m. | OK | GNU C++17 (64) | TESTS | 16 | 15 | 0 | 2800 | |
158476511 | JaroslavUrban | D1 | May 25, 2022, 10:42 p.m. | OK | GNU C++17 (64) | TESTS | 16 | 15 | 0 | 2800 | |
158557958 | Estinka | D1 | May 26, 2022, 6:24 p.m. | OK | GNU C++20 (64) | TESTS | 16 | 0 | 0 | 2800 | |
158517685 | Anonymous_Noob | D1 | May 26, 2022, 10:54 a.m. | OK | GNU C++20 (64) | TESTS | 16 | 0 | 0 | 2800 | |
158484217 | BurnedChicken | D1 | May 26, 2022, 2:56 a.m. | OK | GNU C++20 (64) | TESTS | 16 | 0 | 0 | 2800 | |
158480711 | gyh20 | D1 | May 26, 2022, 1:23 a.m. | OK | GNU C++20 (64) | TESTS | 16 | 0 | 0 | 2800 | |
158469439 | khanh1705 | D1 | May 25, 2022, 8:17 p.m. | OK | GNU C++20 (64) | TESTS | 16 | 0 | 0 | 2800 | |
158460228 | Endagorion | D1 | May 25, 2022, 7:16 p.m. | OK | GNU C++20 (64) | TESTS | 16 | 0 | 0 | 2800 | |
158458839 | Ormlis | D1 | May 25, 2022, 7:10 p.m. | OK | GNU C++20 (64) | TESTS | 16 | 0 | 0 | 2800 | |
158576904 | Kininarimasu | D1 | May 27, 2022, 3:27 a.m. | OK | GNU C++20 (64) | TESTS | 16 | 15 | 0 | 2800 | |
158552208 | Mangooste | D1 | May 26, 2022, 5:10 p.m. | OK | GNU C++20 (64) | TESTS | 16 | 15 | 0 | 2800 | |
158551661 | maximumSHOT | D1 | May 26, 2022, 5:03 p.m. | OK | GNU C++20 (64) | TESTS | 16 | 15 | 0 | 2800 | |
158469774 | Justyo | D1 | May 25, 2022, 8:20 p.m. | OK | Java 11 | TESTS | 16 | 186 | 0 | 2800 | |
158490830 | arvindf232 | D1 | May 26, 2022, 5:03 a.m. | OK | Kotlin 1.4 | TESTS | 16 | 155 | 2048000 | 2800 | |
158465139 | machine_solution | D1 | May 25, 2022, 7:38 p.m. | OK | MS C++ 2017 | TESTS | 16 | 15 | 204800 | 2800 | |
158452698 | whatshisbucket | D1 | May 25, 2022, 6:48 p.m. | OK | PyPy 3 | TESTS | 16 | 77 | 1843200 | 2800 | |
158501438 | Sufiyan18 | D1 | May 26, 2022, 7:26 a.m. | OK | PyPy 3 | TESTS | 16 | 108 | 1843200 | 2800 | |
158536979 | asdsasd | D1 | May 26, 2022, 2:22 p.m. | OK | PyPy 3-64 | TESTS | 16 | 62 | 512000 | 2800 | |
158463439 | plevande | D1 | May 25, 2022, 7:30 p.m. | OK | PyPy 3-64 | TESTS | 16 | 62 | 1945600 | 2800 |
Back to search problems