Codeforces Round 1085 (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
2207 Codeforces Round 1085 (Div. 1 + Div. 2) FINISHED False 10800 3425123 March 8, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 141 ) G Toothless PROGRAMMING constructive algorithms

Let (n, m, a, b) be positive integers with (a \leq b). Toothless is drawing in an (n \times m) grid of sand that is initially all white. In one move, he may do the following: Select any currently white cell and color it black if it has at most one black cell among its edge-adjacent neighbors. Because he is particular about his art, Toothless thinks some cells in the grid are needy , and these cells must end up black. Of the cells that aren't needy, he also thinks some of them are special . A cell has value (b) if it is special, and (a) otherwise. No special cell borders a needy cell by an edge. Let (P) be the sum of the values of all the cells in the grid that aren't needy. Because Toothless is very particular about his art, he wants to make some number of moves such that: Each of the needy cells becomes black after all moves are done, The total value of cells that are colored black ( including needy cells) is at least (\frac{2}{3} \cdot P). Compute any sequence of moves that Toothless could make. Tests are generated in a such way, that it is guaranteed that all of the needy cells in the input can be shaded black after some number of moves. Furthermore, it can be shown that for the given constraints, a satisfying sequence of moves always exists. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains four integers (n), (m), (a), and (b) ((1 \leq n, m \leq 2 \cdot 10^3, 1 \leq n \cdot m \leq 2 \cdot 10^3, 1 \leq a \leq b \leq 5 \cdot 10^5)) — the dimensions of the grid and the values of non-special and special cells, respectively. The (i)-th of the next (n) lines each contain a string (s_i) — a string of exactly (m) characters depicting the (i)-th row of cells. The (j)-th character is ' # ' if the cell at ((i, j)) is needy. The $$$j$

Tutorials

Codeforces Round 1085 (Div. 1 + Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
365911896 hiteshjkh G March 8, 2026, 7:32 p.m. OK C++17 (GCC 7-32) TESTS 205 171 102400
365931731 Symbol_7 G March 9, 2026, 2:25 a.m. OK C++17 (GCC 7-32) TESTS 205 437 102400
365899164 tourist G March 8, 2026, 5:19 p.m. OK C++20 (GCC 13-64) TESTS 205 140 102400
365923829 BenjaminJ G March 8, 2026, 10:38 p.m. OK C++20 (GCC 13-64) TESTS 205 156 102400
365939795 JessieQY G March 9, 2026, 5:12 a.m. OK C++20 (GCC 13-64) TESTS 205 265 102400
365926906 PelicanPilot G March 8, 2026, 11:58 p.m. OK C++20 (GCC 13-64) TESTS 205 1218 102400
365929883 Benq G March 9, 2026, 1:29 a.m. OK C++23 (GCC 14-64, msys2) TESTS 205 93 102400
365928414 generic_placeholder_name G March 9, 2026, 12:44 a.m. OK C++23 (GCC 14-64, msys2) TESTS 205 109 102400
365895820 jiangly G March 8, 2026, 4:59 p.m. OK C++23 (GCC 14-64, msys2) TESTS 205 109 102400
365897860 Elysion G March 8, 2026, 5:11 p.m. OK C++23 (GCC 14-64, msys2) TESTS 205 109 24678400
365901302 sevlll777 G March 8, 2026, 5:30 p.m. OK C++23 (GCC 14-64, msys2) TESTS 205 125 102400
365914203 somethingl45 G March 8, 2026, 8:01 p.m. OK C++23 (GCC 14-64, msys2) TESTS 205 140 102400
365899142 Kapt G March 8, 2026, 5:18 p.m. OK C++23 (GCC 14-64, msys2) TESTS 205 140 110592000
365934500 gopal.thecoder G March 9, 2026, 3:28 a.m. OK C++23 (GCC 14-64, msys2) TESTS 205 187 102400
365921039 ksun48 G March 8, 2026, 9:39 p.m. OK C++23 (GCC 14-64, msys2) TESTS 205 187 102400
365892314 ksun48 G March 8, 2026, 4:39 p.m. OK C++23 (GCC 14-64, msys2) TESTS 205 187 102400
365937812 didxga G March 9, 2026, 4:35 a.m. OK Java 21 TESTS 205 296 1638400
365933685 didxga G March 9, 2026, 3:12 a.m. OK Java 21 TESTS 205 343 3174400
365905400 jdltc G March 8, 2026, 6:13 p.m. OK Java 21 TESTS 205 359 2457600
365901790 Amit-S-Sahu G March 8, 2026, 5:33 p.m. OK Java 21 TESTS 205 421 2969600
365895896 Alex239 G March 8, 2026, 5 p.m. OK PyPy 3-64 TESTS 205 921 11264000

remove filters

Back to search problems