308432: CF1517G. Starry Night Camping
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Starry Night Camping
题意翻译
有 $n$ 顶帐篷,第 $i$个帐篷位于 $(x_i,y_i)$点上,重量为 $w_i$。当且仅当 $x_i$和 $y_i$都是偶数时,帐篷才是重要的。您需要移除一些帐篷,以便对于每个剩余的重要帐篷 $(x,y)$,不存在另外 $3$个帐篷 $(x'_1,y'_1)、(x'_2,y'_2)和(x'_3,y'_3)$,使得这两个条件都成立: - $|x'_j-x|,|y'_j-y|\le 1$,所有 $j\in\{1,2,3\}$。 - 这四个帐篷形成一个平行四边形(或矩形),它的一条边平行于x轴。 请将未移走的帐篷重量之和最大化。打印最大值题目描述
At the foot of Liyushan Mountain, $ n $ tents will be carefully arranged to provide accommodation for those who are willing to experience the joy of approaching nature, the tranquility of the night, and the bright starry sky. The $ i $ -th tent is located at the point of $ (x_i, y_i) $ and has a weight of $ w_i $ . A tent is important if and only if both $ x_i $ and $ y_i $ are even. You need to remove some tents such that for each remaining important tent $ (x, y) $ , there do not exist $ 3 $ other tents $ (x'_1, y'_1) $ , $ (x'_2, y'_2) $ and $ (x'_3, y'_3) $ such that both conditions are true: 1. $ |x'_j-x|, |y'_j - y|\leq 1 $ for all $ j \in \{1, 2, 3\} $ , and 2. these four tents form a parallelogram (or a rectangle) and one of its sides is parallel to the $ x $ -axis. Please maximize the sum of the weights of the tents that are not removed. Print the maximum value.输入输出格式
输入格式
The first line contains a single integer $ n $ ( $ 1\leq n\leq 1\,000 $ ), representing the number of tents. Each of the next $ n $ lines contains three integers $ x_i $ , $ y_i $ and $ w_i $ ( $ -10^9\leq x_i,y_i \leq 10^9 $ , $ 1\leq w_i\leq 10^9 $ ), representing the coordinate of the $ i $ -th tent and its weight. No two tents are located at the same point.
输出格式
A single integer — the maximum sum of the weights of the remaining tents.
输入输出样例
输入样例 #1
5
0 0 4
0 1 5
1 0 3
1 1 1
-1 1 2
输出样例 #1
12
输入样例 #2
32
2 2 1
2 3 1
3 2 1
3 3 1
2 6 1
2 5 1
3 6 1
3 5 1
2 8 1
2 9 1
1 8 1
1 9 1
2 12 1
2 11 1
1 12 1
1 11 1
6 2 1
7 2 1
6 3 1
5 3 1
6 6 1
7 6 1
5 5 1
6 5 1
6 8 1
5 8 1
6 9 1
7 9 1
6 12 1
5 12 1
6 11 1
7 11 1
输出样例 #2
24