Codeforces Round 959 sponsored by NEAR (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
1994 Codeforces Round 959 sponsored by NEAR (Div. 1 + Div. 2) FINISHED False 7200 10509899 July 18, 2024, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 20196 ) A Diverse Game PROGRAMMING constructive algorithms greedy

B"Petr, watching Sergey's stream, came up with a matrix a , consisting of n rows and m columns (the number in the i -th row and j -th column is denoted as a_{i, j} ), which contains all integers from 1 to n cdot m . But he didn't like the arrangement of the numbers, and now he wants to come up with a new matrix b , consisting of n rows and m columns, which will also contain all integers from 1 to n cdot m , such that for any 1 <= q i <= q n, 1 <= q j <= q m it holds that a_{i, j} ne b_{i, j} . You are given the matrix a , construct any matrix b that meets Petr's requirements, or determine that it is impossible. Hurry up! Otherwise, he will donate all his money to the stream in search of an answer to his question. Each test consists of multiple test cases. The first line contains an integer t ( 1 <= q t <= q 10^3 ) -- the number of test cases. Then follows the description of the test cases. The first line of each test case contains two integers n and m ( 1 <= q n, m <= q 10 ) -- the number of rows and columns of matrix a . The next n lines contain m integers each, describing matrix a . The i -th of these lines contains the elements of matrix a_{i, 1}, a_{i, 2}, ldots, a_{i, m} . It is guaranteed that all numbers in matrix a are distinct and 1 <= q a_{i, j} <= q n cdot m . It is guaranteed that the sum of n cdot m over all test cases does not exceed 5 cdot 10^4 . For each test case, output n cdot m integers -- any suitable matrix b , or -1 if such a matrix does not exist. In the first test case, there is only one element in the matrix, so matrix b is the only matrix and it does not fit. In the second test case a_{1, 1} = 2 neq 1 = b_{1, 1} , a_{2, 1} = 1 neq 2 = b_{2, 1} . "...

Tutorials

Video Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
271271657 Geraqlit A July 18, 2024, 5:48 p.m. OK C# 10 TESTS 4 108 3276800
271255151 Im6a A July 18, 2024, 4:12 p.m. OK C# 10 TESTS 4 108 3481600
271271269 Geraqlit A July 18, 2024, 5:45 p.m. OK C# 10 TESTS 4 109 3276800
271273723 DashaK123 A July 18, 2024, 6:03 p.m. OK C# 10 TESTS 4 156 2560000
271274381 zrnstnsr A July 18, 2024, 6:08 p.m. OK C# 10 TESTS 4 171 7987200
271304682 Annliase A July 19, 2024, 1:26 a.m. OK C++14 (GCC 6-32) TESTS 4 31 0
271326382 Hakarishirenai A July 19, 2024, 5:23 a.m. OK C++14 (GCC 6-32) TESTS 4 31 0
271298266 DearJIAN A July 18, 2024, 11:34 p.m. OK C++14 (GCC 6-32) TESTS 4 31 0
271311429 mrf1111 A July 19, 2024, 2:42 a.m. OK C++14 (GCC 6-32) TESTS 4 46 0
271330046 qing221 A July 19, 2024, 5:59 a.m. OK C++14 (GCC 6-32) TESTS 4 46 0
271329613 kanhai- A July 19, 2024, 5:55 a.m. OK C++14 (GCC 6-32) TESTS 4 46 0
271326351 Lane172 A July 19, 2024, 5:23 a.m. OK C++14 (GCC 6-32) TESTS 4 46 0
271319604 ranxi A July 19, 2024, 4:01 a.m. OK C++14 (GCC 6-32) TESTS 4 46 0
271312388 CH3COO_H A July 19, 2024, 2:51 a.m. OK C++14 (GCC 6-32) TESTS 4 46 0
271312330 DF_Pite A July 19, 2024, 2:50 a.m. OK C++14 (GCC 6-32) TESTS 4 46 0
271300512 zhangkaiyang666 A July 19, 2024, 12:21 a.m. OK C++17 (GCC 7-32) TESTS 4 30 8192000
271324974 jangly__ A July 19, 2024, 5:07 a.m. OK C++17 (GCC 7-32) TESTS 4 31 0
271313953 ashutoshojha1217 A July 19, 2024, 3:06 a.m. OK C++17 (GCC 7-32) TESTS 4 31 0
271293552 bshah A July 18, 2024, 9:55 p.m. OK C++17 (GCC 7-32) TESTS 4 31 0
271292019 xer0Eng1ne A July 18, 2024, 9:30 p.m. OK C++17 (GCC 7-32) TESTS 4 31 0
271275993 Arya_Trivedi A July 18, 2024, 6:22 p.m. OK C++17 (GCC 7-32) TESTS 4 31 0
271272886 Free-Free-PaLestine A July 18, 2024, 5:57 p.m. OK C++17 (GCC 7-32) TESTS 4 31 0
271328389 kratos2507 A July 19, 2024, 5:43 a.m. OK C++17 (GCC 7-32) TESTS 4 46 0
271328724 tanish34 A July 19, 2024, 5:47 a.m. OK C++17 (GCC 7-32) TESTS 4 46 0
271328601 Rimjhim_17205 A July 19, 2024, 5:45 a.m. OK C++17 (GCC 7-32) TESTS 4 46 0
271321924 ghost_9 A July 19, 2024, 4:28 a.m. OK C++20 (GCC 13-64) TESTS 4 30 0
271271866 Morsan A July 18, 2024, 5:49 p.m. OK C++20 (GCC 13-64) TESTS 4 30 0
271299786 Sin_Watt A July 19, 2024, 12:08 a.m. OK C++20 (GCC 13-64) TESTS 4 31 0
271297758 yunoo A July 18, 2024, 11:21 p.m. OK C++20 (GCC 13-64) TESTS 4 31 0
271272518 qaruti A July 18, 2024, 5:54 p.m. OK C++20 (GCC 13-64) TESTS 4 31 0
271293329 naghamrjoub A July 18, 2024, 9:52 p.m. OK C++20 (GCC 13-64) TESTS 4 31 0
271329635 9756 A July 19, 2024, 5:55 a.m. OK C++20 (GCC 13-64) TESTS 4 31 0
271328372 FANCHEN A July 19, 2024, 5:43 a.m. OK C++20 (GCC 13-64) TESTS 4 31 0
271307341 kuticpcer A July 19, 2024, 1:57 a.m. OK C++20 (GCC 13-64) TESTS 4 31 0
271304446 noa233 A July 19, 2024, 1:23 a.m. OK C++20 (GCC 13-64) TESTS 4 31 0
271294631 bluemegane A July 18, 2024, 10:14 p.m. OK C# 8 TESTS 4 124 2969600
271256955 WY_ A July 18, 2024, 4:17 p.m. OK GNU C11 TESTS 4 108 0
271260513 b23bb1026 A July 18, 2024, 4:26 p.m. OK GNU C11 TESTS 4 140 0
271329740 atharvatol04 A July 19, 2024, 5:56 a.m. OK GNU C11 TESTS 4 155 102400
271297541 crapcode A July 18, 2024, 11:16 p.m. OK GNU C11 TESTS 4 155 102400
271256122 yogeswararao A July 18, 2024, 4:15 p.m. OK GNU C11 TESTS 4 202 0
271259951 yuhangliu1224 A July 18, 2024, 4:25 p.m. OK Go TESTS 4 77 409600
271299065 1936557 A July 18, 2024, 11:52 p.m. OK Haskell TESTS 4 77 0
271319546 -Jarvis- A July 19, 2024, 4 a.m. OK Java 21 TESTS 4 202 819200
271329419 flyingArpit A July 19, 2024, 5:53 a.m. OK Java 21 TESTS 4 202 1843200
271290552 cf-_- A July 18, 2024, 9:08 p.m. OK Java 21 TESTS 4 233 716800
271293617 shivamCode A July 18, 2024, 9:56 p.m. OK Java 21 TESTS 4 234 409600
271284476 ankush9140 A July 18, 2024, 7:52 p.m. OK Java 21 TESTS 4 234 716800
271279375 vinay_panwar A July 18, 2024, 6:55 p.m. OK Java 21 TESTS 4 296 204800
271282649 parveen21177 A July 18, 2024, 7:31 p.m. OK Java 21 TESTS 4 296 716800
271260137 priyansh_max A July 18, 2024, 4:25 p.m. OK Java 21 TESTS 4 311 614400
271256971 nadeem_not_01 A July 18, 2024, 4:17 p.m. OK Java 21 TESTS 4 311 716800
271321085 anand_mishra_ A July 19, 2024, 4:17 a.m. OK Java 21 TESTS 4 312 0
271320886 wooju.shi A July 19, 2024, 4:15 a.m. OK Java 8 TESTS 4 124 0
271288653 SD125 A July 18, 2024, 8:44 p.m. OK Java 8 TESTS 4 124 0
271314903 kasinathan_sj A July 19, 2024, 3:15 a.m. OK Java 8 TESTS 4 140 0
271295025 yrgoudar A July 18, 2024, 10:22 p.m. OK Java 8 TESTS 4 140 0
271308679 Yousef_Badr A July 19, 2024, 2:12 a.m. OK Java 8 TESTS 4 155 0
271308954 Yousef_Badr A July 19, 2024, 2:16 a.m. OK Java 8 TESTS 4 156 0
271295799 rishabhSrivastava1423 A July 18, 2024, 10:38 p.m. OK Java 8 TESTS 4 171 0
271277675 himneesh9 A July 18, 2024, 6:38 p.m. OK Java 8 TESTS 4 171 0
271257934 faresbadr316 A July 18, 2024, 4:20 p.m. OK Java 8 TESTS 4 171 0
271269417 CipherSphinx_Raj A July 18, 2024, 5:33 p.m. OK Java 8 TESTS 4 187 39321600
271254906 kavya_01 A July 18, 2024, 4:11 p.m. OK Mono C# TESTS 4 155 7270400
271256120 bawal A July 18, 2024, 4:15 p.m. OK PHP TESTS 4 108 102400
271279198 gerogeVT A July 18, 2024, 6:54 p.m. OK PyPy 3 TESTS 4 218 8294400
271325494 yunduoduo A July 19, 2024, 5:13 a.m. OK PyPy 3 TESTS 4 280 8704000
271303625 Giantpanda A July 19, 2024, 1:12 a.m. OK PyPy 3 TESTS 4 311 8294400
271258567 JohnJumon A July 18, 2024, 4:21 p.m. OK PyPy 3 TESTS 4 328 9523200
271255109 nitesh23356 A July 18, 2024, 4:12 p.m. OK PyPy 3 TESTS 4 359 9830400
271271342 028 A July 18, 2024, 5:46 p.m. OK PyPy 3-64 TESTS 4 124 4608000
271262650 harshdew16 A July 18, 2024, 4:32 p.m. OK PyPy 3-64 TESTS 4 124 5017600
271281486 melke_mk A July 18, 2024, 7:18 p.m. OK PyPy 3-64 TESTS 4 140 6860800
271297481 tesn1k A July 18, 2024, 11:14 p.m. OK PyPy 3-64 TESTS 4 140 134963200
271316521 mjukaria9 A July 19, 2024, 3:31 a.m. OK PyPy 3-64 TESTS 4 155 5120000
271292528 alexwice A July 18, 2024, 9:39 p.m. OK PyPy 3-64 TESTS 4 155 5222400
271275477 doubtfulfish A July 18, 2024, 6:18 p.m. OK PyPy 3-64 TESTS 4 155 5222400
271325224 master_JD A July 19, 2024, 5:10 a.m. OK PyPy 3-64 TESTS 4 155 5529600
271325448 jvatsal0709 A July 19, 2024, 5:12 a.m. OK PyPy 3-64 TESTS 4 155 6041600
271270942 ApaarGulati A July 18, 2024, 5:43 p.m. OK PyPy 3-64 TESTS 4 156 5324800
271255287 Glaciel_r A July 18, 2024, 4:12 p.m. OK Python 3 TESTS 4 62 1433600
271275278 Ilyes_Saadaoui A July 18, 2024, 6:16 p.m. OK Python 3 TESTS 4 78 0
271271371 CodeArmy A July 18, 2024, 5:46 p.m. OK Python 3 TESTS 4 78 0
271257103 grizzy_07 A July 18, 2024, 4:17 p.m. OK Python 3 TESTS 4 78 0
271306482 Muhammad.Junaid.Faheem A July 19, 2024, 1:47 a.m. OK Python 3 TESTS 4 92 0
271256241 jvbhalla A July 18, 2024, 4:15 p.m. OK Python 3 TESTS 4 92 0
271324500 akash472sinha A July 19, 2024, 5:01 a.m. OK Python 3 TESTS 4 93 0
271318622 RohithReddy14 A July 19, 2024, 3:51 a.m. OK Python 3 TESTS 4 93 0
271293730 AlgoVortex A July 18, 2024, 9:58 p.m. OK Python 3 TESTS 4 93 0
271270412 OLOGY A July 18, 2024, 5:39 p.m. OK Python 3 TESTS 4 93 0

remove filters

Back to search problems