CF1517G.Starry Night Camping

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

At the foot of Liyushan Mountain, nn 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 ii -th tent is located at the point of (xi,yi)(x_i, y_i) and has a weight of wiw_i . A tent is important if and only if both xix_i and yiy_i are even. You need to remove some tents such that for each remaining important tent (x,y)(x, y) , there do not exist 33 other tents (x1,y1)(x'_1, y'_1) , (x2,y2)(x'_2, y'_2) and (x3,y3)(x'_3, y'_3) such that both conditions are true:

  1. xjx,yjy1|x'_j-x|, |y'_j - y|\leq 1 for all j{1,2,3}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 xx -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 nn ( 1n10001\leq n\leq 1\,000 ), representing the number of tents.

Each of the next nn lines contains three integers xix_i , yiy_i and wiw_i ( 109xi,yi109-10^9\leq x_i,y_i \leq 10^9 , 1wi1091\leq w_i\leq 10^9 ), representing the coordinate of the ii -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

说明/提示

Here is an illustration of the second example. Black triangles indicate the important tents. This example also indicates all 88 forbidden patterns.

首页