QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#13918. 水晶

統計

不用惊慌,今天的题都不是小强出的。——融入了无数心血的作品,现在却不得不亲手毁掉,难以体会他的心情啊。——那也是没有办法的事情,能量共振不消除的话……望着已经被装上炸药的水晶,02 放下了望远镜,看向了手中的共振分析报告。还是会有一些水晶,幸存下来的……也许吧。地图由密铺的六边形单元组成,每个单元与其他六个单元相邻。为了方便起见,我们用坐标 $(x,y,z)$ 描述一个单元的位置,表示从原点开始按如图所示的 $x,y,z$ 方向各走若干步之后到达的地方。有可能有两个坐标描述同一个单元,比如 $(1,1,1)$ 和 $(0,0,0)$ 描述的都是原点

problem_13918_1.png

显然 $(x,y,z)$ 单元和 $(x+1, y,z)$,$(x-1,y,z)$,$(x,y+1,z)$,$(x,y-1,z)$,$(x, y, z+1)$,$(x,y, z-1)$ 相邻。有 $N$ 块水晶位于地图的单元内,第i块水晶位于坐标(xi, yi, zi)所表示的单元中,并拥有ci的价值。每个单元内部可能会有多块水晶。地图中,有一些单元安装有能量源。如下图,任何满足 $x+y+z$ 是 $3$ 的整数倍的坐标所描述的单元内都安装有能量源。

problem_13918_2.png

有能量源的单元中的水晶价值将会额外增加 $10\%$.如果三块水晶所在的单元满足特定排列,那么它们将会引发共振。 共振分两种,a 共振 b 共振

a 共振:如果三块水晶所在的单元两两相邻地排成一个三角形,那么会引起 a 共振。

problem_13918_3.png

图中每一个三角形表示这三个单元各有一块水晶将会发生一个 a 共振。

b 共振:如果三块水晶所在的单元依次相邻地 排成一条长度为2的直线段,且正中间的单元恰好有能量源,那么会引起 b 共振。

problem_13918_4.png

图中粉红色线段表示这三个单元各有一块水晶将会发生一个 b 共振,黑色线段表示即使这三个单元有水晶也不会发生 b 共振。

现在你要炸掉一部分水晶,使得任何共振都不会发生的前提下,剩余水晶的价值总和最大。

输入格式

第一行是一个正整数 $N$,表示水晶数量。

接下来 $N$ 行,每行四个整数 $x_i$,$y_i$,$z_i$,$c_i$,空格分隔,表示一个水晶的位置和价值。

有可能有水晶的位置重合。

输出格式

仅一行,一个实数,表示剩余水晶的价值总和。四舍五入保留1位小数。

样例数据

样例输入

4
0 0 0 11
1 0 0 5
0 1 0 7
0 0 -1 13

样例输出

25.1

样例解释

四块水晶排成一个菱形,没有b共振,有2处a共振,分别是1, 2, 4号水晶和1, 3, 4号水晶形成的三角形。 因此,为了消除两处a共振,有如下3种方案

  1. 炸掉1号水晶,留下2, 3, 4号水晶,总剩余价值5+7+13=25.
  2. 炸掉4号水晶,留下1, 2, 3号水晶,总剩余价值11×(1+10%)+5+7=24.1.
  3. 炸掉2, 3号水晶,留下1, 4号水晶,总剩余价值11×(1+10%)+13=25.1.

因此我们采用第三种方案,最大总剩余价值为25.1.

子任务

对于 $30\%$ 的数据,$N \le 20$.

对于 $60\%$ 的数据,$N \le 100$.

对于 $90\%$ 的数据,$N \le 300$.

对于 $100\%$ 的数据,$N \le 50\,000$,$1 \le c_i \le 1\,000$,$|x_i|, |y_i|, |z_i| \le 1\,000$.

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.