Codeforces Round 877 (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
1838 Codeforces Round 877 (Div. 2) FINISHED False 7200 51290063 June 4, 2023, 2:45 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 15037 ) C No Prime Differences PROGRAMMING constructive algorithms math number theory

B'You are given integers n and m . Fill an n by m grid with the integers 1 through n cdot m , in such a way that for any two adjacent cells in the grid, the absolute difference of the values in those cells is not a prime number. Two cells in the grid are considered adjacent if they share a side. It can be shown that under the given constraints, there is always a solution. The first line of the input contains a single integer t ( 1 <= t <= 1000 ) -- the number of test cases. The description of the test cases follows. The first and only line of each test case contains two integers n and m ( 4 <= n, m <= 1000 ) -- the dimensions of the grid. It is guaranteed that the sum of n cdot m over all test cases does not exceed 10^6 . For each test case, output n lines of m integers each, representing the final grid. Every number from 1 to n cdot m should appear exactly once in the grid. The extra spaces and blank lines in the sample output below are only present to make the output easier to read, and are not required. If there are multiple solutions, print any of them. The first sample case corresponds to the picture above. The only absolute differences between adjacent elements in this grid are 1 , 4 , 6 , 8 , and 9 , none of which are prime. '...

Tutorials

Codeforces Round #877 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
208516390 FatalityNT C June 4, 2023, 6:24 p.m. OK C# 10 TESTS 40 685 17612800
208523876 alsharif.mohamed23 C June 4, 2023, 7:41 p.m. OK GNU C++14 TESTS 40 155 0
208541076 AuroraAlaska C June 5, 2023, 3:14 a.m. OK GNU C++14 TESTS 40 155 7987200
208534453 lostintianyi C June 5, 2023, 12:19 a.m. OK GNU C++14 TESTS 40 155 21196800
208547934 Predator_36 C June 5, 2023, 5:10 a.m. OK GNU C++14 TESTS 40 156 0
208543669 y61329697 C June 5, 2023, 4 a.m. OK GNU C++14 TESTS 40 156 0
208540947 omtrivedioo3 C June 5, 2023, 3:11 a.m. OK GNU C++14 TESTS 40 156 0
208539931 surya_sekhar C June 5, 2023, 2:52 a.m. OK GNU C++14 TESTS 40 156 0
208539196 wzhjk C June 5, 2023, 2:36 a.m. OK GNU C++14 TESTS 40 156 0
208523983 alsharif.mohamed23 C June 4, 2023, 7:42 p.m. OK GNU C++14 TESTS 40 156 0
208523244 justcode_fk C June 4, 2023, 7:33 p.m. OK GNU C++14 TESTS 40 156 0

remove filters

Back to search problems