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.
Problems
B'There is a square grid of size n x n . Some cells are colored in black, all others are colored in white. In one operation you can select some rectangle and color all its cells in white. It costs min(h, w) to color a rectangle of size h x w . You are to make all cells white for minimum total cost. The square is large, so we give it to you in a compressed way. The set of black cells is the union of m rectangles. The first line contains two integers n and m ( 1 <= n <= 10^{9} , 0 <= m <= 50 ) -- the size of the square grid and the number of black rectangles. Each of the next m lines contains 4 integers x_{i1} y_{i1} x_{i2} y_{i2} ( 1 <= x_{i1} <= x_{i2} <= n , 1 <= y_{i1} <= y_{i2} <= n ) -- the coordinates of the bottom-left and the top-right corner cells of the i -th black rectangle. The rectangles may intersect. Print a single integer -- the minimum total cost of painting the whole square in white. The examples and some of optimal solutions are shown on the pictures below. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
58012117 |
hos.lyric |
E |
July 30, 2019, 3:23 p.m. |
OK |
D |
TESTS |
30 |
31 |
4198400 |
|
2500 |
58013168 |
yosupo |
E |
July 30, 2019, 3:26 p.m. |
OK |
D |
TESTS |
30 |
46 |
0 |
|
2500 |
66984682 |
rainboy |
E |
Dec. 15, 2019, 5:39 p.m. |
OK |
GNU C11 |
TESTS |
30 |
31 |
307200 |
|
2500 |
58525861 |
vjudge5 |
E |
Aug. 10, 2019, 7:05 a.m. |
OK |
GNU C++11 |
TESTS |
30 |
30 |
307200 |
|
2500 |
58224964 |
gmh77 |
E |
Aug. 3, 2019, 2:05 p.m. |
OK |
GNU C++11 |
TESTS |
30 |
30 |
1126400 |
|
2500 |
58259116 |
zstu_MingSD |
E |
Aug. 4, 2019, 11:28 a.m. |
OK |
GNU C++11 |
TESTS |
30 |
30 |
2662400 |
|
2500 |
58240929 |
Jaune_Arc |
E |
Aug. 4, 2019, 12:57 a.m. |
OK |
GNU C++11 |
TESTS |
30 |
30 |
4096000 |
|
2500 |
57999112 |
diamond_duke |
E |
July 30, 2019, 2:49 p.m. |
OK |
GNU C++11 |
TESTS |
30 |
30 |
12083200 |
|
2500 |
58336671 |
Dup4 |
E |
Aug. 5, 2019, 11:44 a.m. |
OK |
GNU C++11 |
TESTS |
30 |
30 |
35225600 |
|
2500 |
58523622 |
Cu_Y_Es |
E |
Aug. 10, 2019, 6:07 a.m. |
OK |
GNU C++11 |
TESTS |
30 |
31 |
102400 |
|
2500 |
58386446 |
AutumnKite |
E |
Aug. 6, 2019, 12:08 p.m. |
OK |
GNU C++11 |
TESTS |
30 |
31 |
102400 |
|
2500 |
58063950 |
AutumnKite |
E |
July 31, 2019, 8:20 a.m. |
OK |
GNU C++11 |
TESTS |
30 |
31 |
102400 |
|
2500 |
60267724 |
tmyklebu |
E |
Sept. 8, 2019, 2:06 p.m. |
OK |
GNU C++11 |
TESTS |
30 |
31 |
102400 |
|
2500 |
58507450 |
ccsu_cat_love_jiejie |
E |
Aug. 9, 2019, 5:09 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
15 |
409600 |
|
2500 |
58092056 |
Cinnamoroll |
E |
July 31, 2019, 5:58 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
15 |
512000 |
|
2500 |
63993789 |
cimh |
E |
Nov. 1, 2019, 1:57 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
15 |
1331200 |
|
2500 |
58147785 |
TiChuot97 |
E |
Aug. 1, 2019, 11:40 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
15 |
1433600 |
|
2500 |
58059277 |
mayiyang |
E |
July 31, 2019, 6:45 a.m. |
OK |
GNU C++14 |
TESTS |
30 |
15 |
1536000 |
|
2500 |
58046438 |
DmitryGrigorev |
E |
July 31, 2019, midnight |
OK |
GNU C++14 |
TESTS |
30 |
15 |
1740800 |
|
2500 |
58056581 |
cuom1999 |
E |
July 31, 2019, 5:33 a.m. |
OK |
GNU C++14 |
TESTS |
30 |
15 |
1945600 |
|
2500 |
58714020 |
DeD_TihoN |
E |
Aug. 13, 2019, 1:21 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
15 |
2252800 |
|
2500 |
58131034 |
Linkus |
E |
Aug. 1, 2019, 2:17 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
15 |
5734400 |
|
2500 |
58194005 |
SuperJ6 |
E |
Aug. 2, 2019, 9:52 p.m. |
OK |
GNU C++14 |
TESTS |
30 |
30 |
204800 |
|
2500 |
58263478 |
AlFlen |
E |
Aug. 4, 2019, 1:25 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
15 |
819200 |
|
2500 |
58130607 |
F0_0H |
E |
Aug. 1, 2019, 2:08 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
15 |
1228800 |
|
2500 |
58262223 |
AlFlen |
E |
Aug. 4, 2019, 12:49 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
15 |
1433600 |
|
2500 |
58217260 |
about_30_ninjas |
E |
Aug. 3, 2019, 11:14 a.m. |
OK |
GNU C++17 |
TESTS |
30 |
15 |
1740800 |
|
2500 |
58034985 |
mbrc |
E |
July 30, 2019, 5:54 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
15 |
2355200 |
|
2500 |
58103930 |
2017212212083 |
E |
Aug. 1, 2019, 2:57 a.m. |
OK |
GNU C++17 |
TESTS |
30 |
15 |
2457600 |
|
2500 |
58544126 |
ihave33cm |
E |
Aug. 10, 2019, 3:40 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
15 |
3072000 |
|
2500 |
58526282 |
vjudge4 |
E |
Aug. 10, 2019, 7:17 a.m. |
OK |
GNU C++17 |
TESTS |
30 |
15 |
3481600 |
|
2500 |
58649214 |
armoking |
E |
Aug. 12, 2019, 6:54 a.m. |
OK |
GNU C++17 |
TESTS |
30 |
15 |
4096000 |
|
2500 |
61852354 |
Tneluccus |
E |
Oct. 4, 2019, 1:03 p.m. |
OK |
GNU C++17 |
TESTS |
30 |
15 |
9318400 |
|
2500 |
66984680 |
Dukkha |
E |
Dec. 15, 2019, 5:39 p.m. |
OK |
Java 11 |
TESTS |
30 |
202 |
0 |
|
2500 |
68238401 |
zhanyi_xiaolu |
E |
Jan. 5, 2020, 11:53 a.m. |
OK |
Java 11 |
TESTS |
30 |
233 |
0 |
|
2500 |
58029364 |
uwi |
E |
July 30, 2019, 4:24 p.m. |
OK |
Java 8 |
TESTS |
30 |
124 |
0 |
|
2500 |
58017227 |
niyaznigmatul |
E |
July 30, 2019, 3:40 p.m. |
OK |
Java 8 |
TESTS |
30 |
124 |
0 |
|
2500 |
58006164 |
Petr |
E |
July 30, 2019, 3:06 p.m. |
OK |
Java 8 |
TESTS |
30 |
124 |
0 |
|
2500 |
61778331 |
beginner1010 |
E |
Oct. 3, 2019, 12:24 p.m. |
OK |
Java 8 |
TESTS |
30 |
124 |
0 |
|
2500 |
59069654 |
happybelly |
E |
Aug. 19, 2019, 3:56 a.m. |
OK |
Java 8 |
TESTS |
30 |
124 |
0 |
|
2500 |
59068913 |
happybelly |
E |
Aug. 19, 2019, 3:27 a.m. |
OK |
Java 8 |
TESTS |
30 |
124 |
0 |
|
2500 |
58989785 |
happybelly |
E |
Aug. 18, 2019, 8:44 a.m. |
OK |
Java 8 |
TESTS |
30 |
124 |
0 |
|
2500 |
58038451 |
fetetriste |
E |
July 30, 2019, 6:40 p.m. |
OK |
Java 8 |
TESTS |
30 |
124 |
0 |
|
2500 |
59069970 |
happybelly |
E |
Aug. 19, 2019, 4:08 a.m. |
OK |
Java 8 |
TESTS |
30 |
139 |
0 |
|
2500 |
59382791 |
gamesterrex |
E |
Aug. 24, 2019, 4:33 a.m. |
OK |
Java 8 |
TESTS |
30 |
140 |
0 |
|
2500 |
58026997 |
darnley |
E |
July 30, 2019, 4:15 p.m. |
OK |
Kotlin |
TESTS |
30 |
170 |
1433600 |
|
2500 |
58461923 |
darnley |
E |
Aug. 8, 2019, 5:02 p.m. |
OK |
Kotlin |
TESTS |
30 |
186 |
1433600 |
|
2500 |
58147159 |
claw88 |
E |
Aug. 1, 2019, 10:42 p.m. |
OK |
Mono C# |
TESTS |
30 |
77 |
4198400 |
|
2500 |
58020566 |
riantkb |
E |
July 30, 2019, 3:51 p.m. |
OK |
Mono C# |
TESTS |
30 |
92 |
5632000 |
|
2500 |
58140596 |
claw88 |
E |
Aug. 1, 2019, 5:57 p.m. |
OK |
Mono C# |
TESTS |
30 |
92 |
7168000 |
|
2500 |
59693735 |
vjudge2 |
E |
Aug. 30, 2019, 7:30 a.m. |
OK |
MS C++ |
TESTS |
30 |
31 |
11571200 |
|
2500 |
58268794 |
TOXait |
E |
Aug. 4, 2019, 3:55 p.m. |
OK |
MS C++ 2017 |
TESTS |
30 |
30 |
1740800 |
|
2500 |
58036983 |
Milanin |
E |
July 30, 2019, 6:16 p.m. |
OK |
MS C++ 2017 |
TESTS |
30 |
31 |
1740800 |
|
2500 |
59117927 |
linwe |
E |
Aug. 20, 2019, 2:57 a.m. |
OK |
PyPy 3 |
TESTS |
30 |
218 |
3481600 |
|
2500 |
65507546 |
sansen |
E |
Nov. 22, 2019, 12:29 a.m. |
OK |
Rust |
TESTS |
30 |
46 |
1843200 |
|
2500 |
remove filters
Back to search problems