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
Steve Rogers is fascinated with new vibranium shields S.H.I.E.L.D gave him. They're all uncolored. There are n shields in total, the i -th shield is located at point ( x i , y i ) of the coordinate plane. It's possible that two or more shields share the same location. Steve wants to paint all these shields. He paints each shield in either red or blue. Painting a shield in red costs r dollars while painting it in blue costs b dollars. Additionally, there are m constraints Steve wants to be satisfied. The i -th constraint is provided by three integers t i , l i and d i : If t i = 1 , then the absolute difference between the number of red and blue shields on line x = l i should not exceed d i . If t i = 2 , then the absolute difference between the number of red and blue shields on line y = l i should not exceed d i . Steve gave you the task of finding the painting that satisfies all the condition and the total cost is minimum. The first line of the input contains two integers n and m ( 1 ≤ n , m ≤ 100 000 ) — the number of shields and the number of constraints respectively. The second line contains two integers r and b ( 1 ≤ r , b ≤ 10 9 ). The next n lines contain the shields coordinates. The i -th of these lines contains two integers x i and y i ( 1 ≤ x i , y i ≤ 10 9 ). The next m lines contain the constrains. The j -th of these lines contains three integers t j , l j and d j ( 1 ≤ t j ≤ 2, 1 ≤ l j ≤ 10 9 , 0 ≤ d j ≤ n ). If satisfying all the constraints is impossible print -1 in first and only line of the output. Otherwise, print the minimum total cost in the first line of output. In the second line print a string of length n consisting of letters ' r ' and ' b ' only. The i -th character should be ' r ' if the i -th shield should be painted red in the optimal answer and ' b ' if it should be painted blue. The cost of painting shields in these colors should be equal the minimum cost you printed on the first line. If there exist more than one optimal solu |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
42348231 |
Scut82 |
D |
Sept. 2, 2018, 1:15 a.m. |
OK |
GNU C++ |
TESTS |
71 |
108 |
37376000 |
|
3000 |
|
21587292 |
SoiMae |
D |
Oct. 19, 2016, 9:23 a.m. |
OK |
GNU C++ |
TESTS |
71 |
140 |
35737600 |
|
3000 |
|
26320137 |
jiyutian |
D |
April 12, 2017, 2:46 p.m. |
OK |
GNU C++ |
TESTS |
71 |
171 |
21913600 |
|
3000 |
|
26104012 |
zyding |
D |
April 3, 2017, 4:05 p.m. |
OK |
GNU C++ |
TESTS |
71 |
171 |
26112000 |
|
3000 |
|
39811515 |
ObKsEm |
D |
July 1, 2018, 3:43 a.m. |
OK |
GNU C++ |
TESTS |
71 |
171 |
56934400 |
|
3000 |
|
40115431 |
mengbierr |
D |
July 9, 2018, 2:20 p.m. |
OK |
GNU C++ |
TESTS |
71 |
171 |
57036800 |
|
3000 |
|
37211000 |
beginend |
D |
April 11, 2018, 8:43 a.m. |
OK |
GNU C++ |
TESTS |
71 |
171 |
60620800 |
|
3000 |
|
33257301 |
vjudge4 |
D |
Dec. 15, 2017, 7:29 a.m. |
OK |
GNU C++ |
TESTS |
71 |
171 |
178892800 |
|
3000 |
|
33257278 |
Lyrancel |
D |
Dec. 15, 2017, 7:28 a.m. |
OK |
GNU C++ |
TESTS |
71 |
171 |
178892800 |
|
3000 |
|
20488375 |
FHW_SO_WALL |
D |
Sept. 10, 2016, 1:32 a.m. |
OK |
GNU C++ |
TESTS |
71 |
186 |
26316800 |
|
3000 |
|
51225664 |
Chlience |
D |
March 12, 2019, 2:01 p.m. |
OK |
GNU C++11 |
TESTS |
71 |
93 |
43929600 |
|
3000 |
|
51224217 |
Chlience |
D |
March 12, 2019, 1:31 p.m. |
OK |
GNU C++11 |
TESTS |
71 |
93 |
43929600 |
|
3000 |
|
69594761 |
justin_cao |
D |
Jan. 27, 2020, 3:46 a.m. |
OK |
GNU C++11 |
TESTS |
71 |
109 |
29081600 |
|
3000 |
|
69594539 |
justin_cao |
D |
Jan. 27, 2020, 3:34 a.m. |
OK |
GNU C++11 |
TESTS |
71 |
109 |
29081600 |
|
3000 |
|
48206450 |
ww3113306 |
D |
Jan. 11, 2019, 9:08 a.m. |
OK |
GNU C++11 |
TESTS |
71 |
109 |
69632000 |
|
3000 |
|
60510647 |
luogu_bot5 |
D |
Sept. 14, 2019, 2:38 a.m. |
OK |
GNU C++11 |
TESTS |
71 |
124 |
19660800 |
|
3000 |
|
69242278 |
luogu_bot3 |
D |
Jan. 21, 2020, 11:48 a.m. |
OK |
GNU C++11 |
TESTS |
71 |
124 |
23244800 |
|
3000 |
|
36567899 |
ohweonfire |
D |
March 24, 2018, 8:18 a.m. |
OK |
GNU C++11 |
TESTS |
71 |
124 |
39424000 |
|
3000 |
|
69233393 |
AloneKnight |
D |
Jan. 21, 2020, 10:22 a.m. |
OK |
GNU C++11 |
TESTS |
71 |
139 |
23449600 |
|
3000 |
|
66214979 |
luhong |
D |
Dec. 3, 2019, 8:31 a.m. |
OK |
GNU C++11 |
TESTS |
71 |
140 |
31744000 |
|
3000 |
|
26591699 |
Egor.Lifar |
D |
April 22, 2017, 9:05 p.m. |
OK |
GNU C++14 |
TESTS |
71 |
78 |
35635200 |
|
3000 |
|
65714835 |
Created_equal |
D |
Nov. 25, 2019, 4:04 p.m. |
OK |
GNU C++14 |
TESTS |
71 |
109 |
60723200 |
|
3000 |
|
37832974 |
Marco_L_T |
D |
May 2, 2018, 7:19 a.m. |
OK |
GNU C++14 |
TESTS |
71 |
124 |
28364800 |
|
3000 |
|
37832984 |
Marco_L_T |
D |
May 2, 2018, 7:19 a.m. |
OK |
GNU C++14 |
TESTS |
71 |
171 |
28364800 |
|
3000 |
|
63231106 |
ObKsEm |
D |
Oct. 23, 2019, 11 a.m. |
OK |
GNU C++14 |
TESTS |
71 |
186 |
57139200 |
|
3000 |
|
20560646 |
snowy_smile |
D |
Sept. 13, 2016, 5:44 a.m. |
OK |
GNU C++14 |
TESTS |
71 |
187 |
20070400 |
|
3000 |
|
66167770 |
yhx-12243 |
D |
Dec. 2, 2019, 8:36 a.m. |
OK |
GNU C++14 |
TESTS |
71 |
187 |
41164800 |
|
3000 |
|
67687932 |
rushcheyo |
D |
Dec. 27, 2019, 9:45 a.m. |
OK |
GNU C++14 |
TESTS |
71 |
202 |
16691200 |
|
3000 |
|
35088883 |
cyz666 |
D |
Feb. 9, 2018, 12:10 p.m. |
OK |
GNU C++14 |
TESTS |
71 |
202 |
25292800 |
|
3000 |
|
26129160 |
unused |
D |
April 4, 2017, 5:35 p.m. |
OK |
GNU C++14 |
TESTS |
71 |
202 |
25497600 |
|
3000 |
|
56731544 |
iotang |
D |
July 9, 2019, 1:49 a.m. |
OK |
GNU C++17 |
TESTS |
71 |
171 |
66969600 |
|
3000 |
|
63127696 |
jiangly |
D |
Oct. 22, 2019, 1:17 p.m. |
OK |
GNU C++17 |
TESTS |
71 |
202 |
19046400 |
|
3000 |
|
69571117 |
vjudge4 |
D |
Jan. 26, 2020, 2:07 p.m. |
OK |
GNU C++17 |
TESTS |
71 |
202 |
66867200 |
|
3000 |
|
60386714 |
Avalonal |
D |
Sept. 11, 2019, 11:49 a.m. |
OK |
GNU C++17 |
TESTS |
71 |
202 |
175411200 |
|
3000 |
|
63689587 |
jiangly |
D |
Oct. 29, 2019, 1:29 a.m. |
OK |
GNU C++17 |
TESTS |
71 |
218 |
19046400 |
|
3000 |
|
68866049 |
hjk1030 |
D |
Jan. 15, 2020, 1:39 p.m. |
OK |
GNU C++17 |
TESTS |
71 |
218 |
31436800 |
|
3000 |
|
54861353 |
Zhang_RQ |
D |
May 31, 2019, 2:19 a.m. |
OK |
GNU C++17 |
TESTS |
71 |
233 |
34099200 |
|
3000 |
|
60386739 |
vjudge1 |
D |
Sept. 11, 2019, 11:50 a.m. |
OK |
GNU C++17 |
TESTS |
71 |
233 |
175411200 |
|
3000 |
|
51223677 |
Chlience |
D |
March 12, 2019, 1:22 p.m. |
OK |
GNU C++17 |
TESTS |
71 |
249 |
47923200 |
|
3000 |
|
51223045 |
Chlience |
D |
March 12, 2019, 1:09 p.m. |
OK |
GNU C++17 |
TESTS |
71 |
249 |
47923200 |
|
3000 |
|
21829601 |
JialinOuyang |
D |
Oct. 27, 2016, 4:53 p.m. |
OK |
Java 8 |
TESTS |
71 |
327 |
77004800 |
|
3000 |
|
20673634 |
JialinOuyang |
D |
Sept. 17, 2016, 5:30 a.m. |
OK |
Java 8 |
TESTS |
71 |
358 |
77004800 |
|
3000 |
|
20078746 |
JialinOuyang |
D |
Aug. 23, 2016, 6:39 a.m. |
OK |
Java 8 |
TESTS |
71 |
467 |
84889600 |
|
3000 |
|
51563908 |
vjudge3 |
D |
March 20, 2019, 8:59 a.m. |
OK |
MS C++ |
TESTS |
71 |
296 |
33280000 |
|
3000 |
|
62449306 |
typeryougishiki |
D |
Oct. 13, 2019, 2:45 a.m. |
OK |
MS C++ 2017 |
TESTS |
71 |
748 |
238796800 |
|
3000 |
remove filters
Back to search problems