Codeforces Round 854 by cybercats (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
1799 Codeforces Round 854 by cybercats (Div. 1 + Div. 2) FINISHED False 10800 54314699 Feb. 27, 2023, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 1221 ) E City Union PROGRAMMING constructive algorithms dp geometry greedy implementation math

B"You are given n x m grid. Some cells are filled and some are empty. A city is a maximal (by inclusion) set of filled cells such that it is possible to get from any cell in the set to any other cell in the set by moving to adjacent (by side) cells, without moving into any cells not in the set. In other words, a city is a connected component of filled cells with edges between adjacent (by side) cells. Initially, there are two cities on the grid. You want to change some empty cells into filled cells so that both of the following are satisfied: The Manhattan distance between two cells (a, b) and (c, d) is equal to |a - c| + |b - d| . Find a way to add filled cells that satisfies these conditions and minimizes the total number of filled cells. Input consists of multiple test cases. The first line contains a single integer t , the number of test cases ( 1 <= t <= 5000 ). The first line of each test case contains two integers n and m ( 1 <= n, m <= 50 , nm geq 3 ). The next n lines describe the grid. The i -th line contains a string s_i of length m . s_{i,j} is '#' if the cell in position (i, j) is filled, and '.' if it is empty. It is guaranteed that there are exactly two cities in the initial grid. It is guaranteed that the sum of n cdot m over all test cases does not exceed 25 ,000 . For each test case, output n lines, each containing a string of length m , describing the grid you create in the same format as the input. If there are multiple possible answers with the minimum number of filled cells print any. In the first test case, we can add a single filled cell between the two cities to connect them. We can verify that the second condition is satisfied. In the second test case, we can also connect the cities with a single filled cell, while satisfying the second condition. In the third test case, note that if we filled the 3 cells in the t"...

Tutorials

Codeforces Round #854 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
195172157 KumaTachiRen E Feb. 27, 2023, 4:18 p.m. OK C# 8 TESTS 67 93 3379200
195195762 rainboy E Feb. 27, 2023, 6:25 p.m. OK GNU C11 TESTS 69 46 0
195177779 william556 E Feb. 27, 2023, 4:41 p.m. OK GNU C++14 TESTS 67 15 0
195174918 meteor_shower E Feb. 27, 2023, 4:29 p.m. OK GNU C++14 TESTS 67 15 0
195185702 nhho E Feb. 27, 2023, 5:17 p.m. OK GNU C++14 TESTS 67 15 0
195182601 Xu_Hongxi E Feb. 27, 2023, 5:03 p.m. OK GNU C++14 TESTS 67 15 0
195171019 LinRui E Feb. 27, 2023, 4:13 p.m. OK GNU C++14 TESTS 67 15 102400
195182965 Jimanbanashi E Feb. 27, 2023, 5:05 p.m. OK GNU C++14 TESTS 67 15 102400
195183188 buko E Feb. 27, 2023, 5:06 p.m. OK GNU C++14 TESTS 67 15 102400
195226488 foammm E Feb. 28, 2023, 3:57 a.m. OK GNU C++14 TESTS 69 15 307200
195187593 awoo E Feb. 27, 2023, 5:26 p.m. OK GNU C++14 TESTS 67 15 307200
195188379 dancho E Feb. 27, 2023, 5:29 p.m. OK GNU C++14 TESTS 67 15 307200
195184770 last_cai E Feb. 27, 2023, 5:13 p.m. OK GNU C++17 TESTS 67 15 0
195214552 lddlinan E Feb. 27, 2023, 10:41 p.m. OK GNU C++17 TESTS 69 15 0
195227833 RNS_PWR E Feb. 28, 2023, 4:24 a.m. OK GNU C++17 TESTS 69 15 0
195218250 ocarima E Feb. 28, 2023, 12:27 a.m. OK GNU C++17 TESTS 69 15 0
195228913 hibye1217 E Feb. 28, 2023, 4:46 a.m. OK GNU C++17 TESTS 69 15 102400
195184636 TrivialMan E Feb. 27, 2023, 5:12 p.m. OK GNU C++17 TESTS 67 15 102400
195182127 Mtaylor E Feb. 27, 2023, 5:01 p.m. OK GNU C++17 TESTS 67 15 102400
195177951 AliShahali1382 E Feb. 27, 2023, 4:42 p.m. OK GNU C++17 TESTS 67 15 102400
195186366 Keli-add E Feb. 27, 2023, 5:20 p.m. OK GNU C++17 TESTS 67 15 204800
195185173 sg0071729 E Feb. 27, 2023, 5:15 p.m. OK GNU C++17 TESTS 67 15 204800
195193221 diskoteka E Feb. 27, 2023, 6:08 p.m. OK GNU C++17 (64) TESTS 69 15 0
195220102 Lynkcat E Feb. 28, 2023, 1:27 a.m. OK GNU C++17 (64) TESTS 69 15 0
195182371 andrei_boaca E Feb. 27, 2023, 5:02 p.m. OK GNU C++17 (64) TESTS 67 15 0
195178893 frokaikan E Feb. 27, 2023, 4:46 p.m. OK GNU C++17 (64) TESTS 67 15 0
195178326 torisasami E Feb. 27, 2023, 4:43 p.m. OK GNU C++17 (64) TESTS 67 15 0
195177543 Xylenox E Feb. 27, 2023, 4:40 p.m. OK GNU C++17 (64) TESTS 67 15 0
195176353 Kude E Feb. 27, 2023, 4:35 p.m. OK GNU C++17 (64) TESTS 67 15 0
195175533 Little09 E Feb. 27, 2023, 4:31 p.m. OK GNU C++17 (64) TESTS 67 15 0
195174615 ALILILILILI-KHAN E Feb. 27, 2023, 4:28 p.m. OK GNU C++17 (64) TESTS 67 15 0
195188085 Siberian E Feb. 27, 2023, 5:28 p.m. OK GNU C++17 (64) TESTS 67 15 102400
195225008 jeroenodb E Feb. 28, 2023, 3:31 a.m. OK GNU C++20 (64) TESTS 69 15 0
195224861 Randias E Feb. 28, 2023, 3:28 a.m. OK GNU C++20 (64) TESTS 69 15 0
195224840 jeroenodb E Feb. 28, 2023, 3:28 a.m. OK GNU C++20 (64) TESTS 69 15 0
195224271 propane E Feb. 28, 2023, 3:15 a.m. OK GNU C++20 (64) TESTS 69 15 0
195219134 Paul_Liao_1457 E Feb. 28, 2023, 12:55 a.m. OK GNU C++20 (64) TESTS 69 15 0
195205403 WAtoAC2001 E Feb. 27, 2023, 8:11 p.m. OK GNU C++20 (64) TESTS 69 15 0
195205309 yeobo1729 E Feb. 27, 2023, 8:10 p.m. OK GNU C++20 (64) TESTS 69 15 0
195204103 gongkoufadongji E Feb. 27, 2023, 7:54 p.m. OK GNU C++20 (64) TESTS 69 15 0
195203455 gongkoufadongji E Feb. 27, 2023, 7:46 p.m. OK GNU C++20 (64) TESTS 69 15 0
195225049 jeroenodb E Feb. 28, 2023, 3:32 a.m. OK GNU C++20 (64) TESTS 69 15 0
195184758 knightL E Feb. 27, 2023, 5:13 p.m. OK Java 17 TESTS 67 249 512000
195187690 Dukkha E Feb. 27, 2023, 5:26 p.m. OK Java 17 TESTS 67 280 921600
195178864 fetetriste E Feb. 27, 2023, 4:46 p.m. OK Java 8 TESTS 67 139 0
195194226 IanISam E Feb. 27, 2023, 6:14 p.m. OK Java 8 TESTS 69 140 0
195187478 Beduardo E Feb. 27, 2023, 5:25 p.m. OK Kotlin 1.6 TESTS 67 249 1024000
195222396 clam E Feb. 28, 2023, 2:32 a.m. OK PyPy 3-64 TESTS 69 217 9830400
195222476 FlakeLCR E Feb. 28, 2023, 2:34 a.m. OK PyPy 3-64 TESTS 69 217 9932800
195223157 FlakeLCR E Feb. 28, 2023, 2:51 a.m. OK PyPy 3-64 TESTS 69 233 9830400
195224305 SugoiTurtle E Feb. 28, 2023, 3:16 a.m. OK PyPy 3-64 TESTS 69 343 10752000
195194231 samriddhjn E Feb. 27, 2023, 6:14 p.m. OK PyPy 3-64 TESTS 69 389 10649600
195213314 jerome_coding E Feb. 27, 2023, 10:14 p.m. OK PyPy 3-64 TESTS 69 389 10854400
195176403 titia E Feb. 27, 2023, 4:35 p.m. OK PyPy 3-64 TESTS 67 404 10444800
195185552 dyppp E Feb. 27, 2023, 5:17 p.m. OK PyPy 3-64 TESTS 67 436 10752000
195181211 alexwice E Feb. 27, 2023, 4:56 p.m. OK PyPy 3-64 TESTS 67 452 10854400
195179472 plevande E Feb. 27, 2023, 4:49 p.m. OK PyPy 3-64 TESTS 67 530 10649600
195170802 chaotic_iak E Feb. 27, 2023, 4:13 p.m. OK Python 3 TESTS 67 233 0
195178569 sansen E Feb. 27, 2023, 4:44 p.m. OK Rust 2021 TESTS 67 15 614400

remove filters

Back to search problems