Codeforces Round 802 (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
1700 Codeforces Round 802 (Div. 2) FINISHED False 7200 81550463 June 19, 2022, 9:05 a.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 888 ) E Serega the Pirate PROGRAMMING brute force constructive algorithms 2600

B"Little pirate Serega robbed a ship with puzzles of different kinds. Among all kinds, he liked only one, the hardest. A puzzle is a table of n rows and m columns, whose cells contain each number from 1 to n cdot m exactly once. To solve a puzzle, you have to find a sequence of cells in the table, such that any two consecutive cells are adjacent by the side in the table. The sequence can have arbitrary length and should visit each cell one or more times. For a cell containing the number i , denote the position of the first occurrence of this cell in the sequence as t_i . The sequence solves the puzzle, if t_1 < t_2 < ... < t_{nm} . In other words, the cell with number x should be first visited before the cell with number x + 1 for each x . Let's call a puzzle solvable, if there exists at least one suitable sequence. In one move Serega can choose two arbitrary cells in the table (not necessarily adjacent by the side) and swap their numbers. He would like to know the minimum number of moves to make his puzzle solvable, but he is too impatient. Thus, please tell if the minimum number of moves is 0 , 1 , or at least 2 . In the case, where 1 move is required, please also find the number of suitable cell pairs to swap. In the first line there are two whole positive numbers n, m ( 1 <= q n cdot m <= q 400 ,000 ) -- table dimensions. In the next n lines there are m integer numbers a_{i1}, a_{i2}, ... , a_{im} ( 1 <= a_{ij} <= nm ). It is guaranteed that every number from 1 to nm occurs exactly once in the table. Let a be the minimum number of moves to make the puzzle solvable. If a = 0 , print 0 . If a = 1 , print 1 and the number of valid swaps. If a ge 2 , print 2 . In the first example the sequence (1, 2), (1, 1), (1, 2), (1, 3), (2, 3), (3, 3) , (2, 3), (1, 3), (1, 2), (1, 1), (2, 1), (2, "...

Tutorials

103978

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
161231111 zmj2008AKIOI E June 19, 2022, 1:46 p.m. OK GNU C++14 TESTS 84 249 11673600 2600
161219786 by_chance E June 19, 2022, 11:43 a.m. OK GNU C++14 TESTS 84 265 6451200 2600
161220253 antguz E June 19, 2022, 11:47 a.m. OK GNU C++14 TESTS 84 342 8806400 2600
161272724 BARBARIANNNNN E June 20, 2022, 5:23 a.m. OK GNU C++14 TESTS 84 436 4915200 2600
161209759 chenrui9551 E June 19, 2022, 10:46 a.m. OK GNU C++14 TESTS 84 468 3891200 2600
161221555 peiwenjun E June 19, 2022, 11:58 a.m. OK GNU C++14 TESTS 84 577 26419200 2600
161217369 anodiebird E June 19, 2022, 11:26 a.m. OK GNU C++14 TESTS 84 670 13209600 2600
161261759 CQYZWJH E June 19, 2022, 11:52 p.m. OK GNU C++14 TESTS 84 904 19763200 2600
161244075 SuperJ6 E June 19, 2022, 4:51 p.m. OK GNU C++14 TESTS 84 1013 31744000 2600
161229310 Defoliation_luoch E June 19, 2022, 1:25 p.m. OK GNU C++14 TESTS 84 1637 57036800 2600
161235656 Bobocan E June 19, 2022, 2:47 p.m. OK GNU C++17 TESTS 84 46 3993600 2600
161241245 trek_walker E June 19, 2022, 4:12 p.m. OK GNU C++17 TESTS 84 139 10649600 2600
161218434 acwing_meow E June 19, 2022, 11:33 a.m. OK GNU C++17 TESTS 84 171 7987200 2600
161273719 system_1 E June 20, 2022, 5:41 a.m. OK GNU C++17 TESTS 84 187 4812800 2600
161262126 Ashlan E June 20, 2022, 12:13 a.m. OK GNU C++17 TESTS 84 218 4812800 2600
161245800 Hasan0540 E June 19, 2022, 5:16 p.m. OK GNU C++17 TESTS 84 249 6348800 2600
161226432 cxy004 E June 19, 2022, 12:52 p.m. OK GNU C++17 TESTS 84 265 3174400 2600
161215179 cxy004 E June 19, 2022, 11:03 a.m. OK GNU C++17 TESTS 84 265 3174400 2600
161246152 Hasan0540 E June 19, 2022, 5:22 p.m. OK GNU C++17 TESTS 84 265 6348800 2600
161209815 Whiteqwq E June 19, 2022, 10:46 a.m. OK GNU C++17 TESTS 84 342 13209600 2600
161213904 ivatopuria E June 19, 2022, 11 a.m. OK GNU C++17 (64) TESTS 84 187 31027200 2600
161219188 houzhiyuan123 E June 19, 2022, 11:39 a.m. OK GNU C++17 (64) TESTS 84 265 16896000 2600
161220853 ivatopuria E June 19, 2022, 11:52 a.m. OK GNU C++17 (64) TESTS 84 280 31027200 2600
161274895 Beevo E June 20, 2022, 6:01 a.m. OK GNU C++17 (64) TESTS 84 327 9625600 2600
161222217 DOngPH19 E June 19, 2022, 12:05 p.m. OK GNU C++17 (64) TESTS 84 420 16076800 2600
161246087 Nanako E June 19, 2022, 5:21 p.m. OK GNU C++17 (64) TESTS 84 686 27443200 2600
161211460 11231123 E June 19, 2022, 10:52 a.m. OK GNU C++17 (64) TESTS 84 857 17100800 2600
161223426 elena44xx E June 19, 2022, 12:18 p.m. OK GNU C++17 (64) TESTS 84 872 5836800 2600
161262510 dean.menezes E June 20, 2022, 12:33 a.m. OK GNU C++17 (64) TESTS 84 951 32972800 2600
161261044 kal013 E June 19, 2022, 11:11 p.m. OK GNU C++17 (64) TESTS 84 1170 3174400 2600
161257401 arbuzick E June 19, 2022, 8:49 p.m. OK GNU C++20 (64) TESTS 84 77 7475200 2600
161240760 sky123 E June 19, 2022, 4:05 p.m. OK GNU C++20 (64) TESTS 84 93 5836800 2600
161219183 Ivan_len E June 19, 2022, 11:39 a.m. OK GNU C++20 (64) TESTS 84 124 9011200 2600
161219079 Ivan_len E June 19, 2022, 11:38 a.m. OK GNU C++20 (64) TESTS 84 124 9011200 2600
161211257 S2speed E June 19, 2022, 10:51 a.m. OK GNU C++20 (64) TESTS 84 124 17100800 2600
161274477 hunanligong E June 20, 2022, 5:55 a.m. OK GNU C++20 (64) TESTS 84 140 33689600 2600
161213491 Nero E June 19, 2022, 10:59 a.m. OK GNU C++20 (64) TESTS 84 155 5836800 2600
161222007 Lokeo E June 19, 2022, 12:03 p.m. OK GNU C++20 (64) TESTS 84 156 19251200 2600
161274204 hunanligong E June 20, 2022, 5:51 a.m. OK GNU C++20 (64) TESTS 84 156 61440000 2600
161240045 sky123 E June 19, 2022, 3:56 p.m. OK GNU C++20 (64) TESTS 84 186 5836800 2600
161220629 taran_1407 E June 19, 2022, 11:50 a.m. OK Java 11 TESTS 84 1902 28467200 2600

remove filters

Back to search problems