弱省胡策 Round 3 Avalon【可并堆】【计算几何】
来源:互联网 发布:win7组策略优化 编辑:程序博客网 时间:2024/06/15 20:17
#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>#include <iostream>#include <fstream>#include <map>#include <ext/pb_ds/priority_queue.hpp>using namespace std;typedef long long ll;typedef pair<int, int> pii;const int maxn = 1000010;const int inf = 0x3f3f3f3f;inline ll read(){ll x = 0, f = 1; char c = getchar();while (c < '0' || c > '9')f = (c == '-' ? -1 : 1), c = getchar();while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();return x * f;}__gnu_pbds::priority_queue<pii> Pb[maxn], Pr[maxn];struct edge{int v, next;} e[maxn];struct point{double x, y; int w;} p[maxn];struct query{double the; int pr;}arc[maxn];int n, k, l, cnt, b[maxn], r[maxn], pr[maxn], head[maxn], fa[maxn], in[maxn], deep[maxn];ll B[maxn], R[maxn];void insert(int u, int v){e[cnt] = (edge) {v, head[u]}, head[u] = cnt++;}void dfs(int u){Pb[u].push(make_pair(deep[u], b[u]));Pr[u].push(make_pair(deep[u], r[u]));for (int i = head[u]; i != -1; i = e[i].next) {int v = e[i].v;deep[v] = deep[u] + 1, dfs(v);Pb[u].join(Pb[v]), B[u] += B[v]; Pr[u].join(Pr[v]), R[u] += R[v];}while (Pb[u].top().first - k >= deep[u])B[u] -= Pb[u].top().second, Pb[u].pop();while (Pr[u].top().first - k >= deep[u])R[u] -= Pr[u].top().second, Pr[u].pop();}double dis(point a, point b){double x = a.x - b.x, y = a.y - b.y;return sqrt(x * x + y * y);}bool cmp(query a, query b){return a.the < b.the || a.the == b.the && a.pr > b.pr;}void Max_Circle_Cover(){ll ans = 0;for (int i = 0; i < cnt; i++) {int sum = 0;for (int j = 0; j < cnt; j++)if (i != j && dis(p[i], p[j]) <= 2.0 * l) {double the = atan2((p[i].y - p[j].y), (p[i].x - p[j].x));double phi = acos(dis(p[i], p[j]) / (2.0 * l));arc[sum++] = (query) {the - phi, p[j].w};arc[sum++] = (query) {the + phi, -p[j].w};}sort(arc, arc + sum, cmp);ll tmp = p[i].w;for (int j = 0; j < sum; j++) { tmp += arc[j].pr;ans = max(ans, tmp);}}cout << ans << endl;}int main(){freopen("sample.in", "r", stdin);n = read(), k = read(), l = read();memset(head, -1, sizeof head);for (int i = 1; i <= n; i++) {b[i] = B[i] = read();r[i] = R[i] = read(); pr[i] = read();fa[i] = read(); in[i] = read();if (fa[i] != -1)insert(fa[i], i);}dfs(1), cnt = 0;for (int i = 1; i <= n; i++)if (in[i] == 1)p[cnt++] = (point) {B[i], R[i], pr[i]};Max_Circle_Cover();return 0;}
0 0
- 弱省胡策 Round 3 Avalon【可并堆】【计算几何】
- HDU1512 可并堆
- 【模板】可并堆
- 可并堆?左偏树?
- 可并堆模板
- 可并堆
- 左偏树(可并堆)
- HDU1512 左偏树(可并堆)
- 猴子大王 可并堆
- 可并堆之左偏树
- luogu 3377 可并堆
- 【左偏树(可并堆)模板】
- BestCoder Round #12 War(计算几何)
- Educational Codeforces Round 11 D 计算几何
- 可并堆与二叉堆
- ZOJ 2334 可并堆<斜堆>
- 计算几何练习3
- 【计算几何】圆的面积并
- js防止事件冒泡和默认事件
- 中国气象网 气象数据开放平台 API使用方法 (Android)(已废弃)
- 自定义弹出框alert
- 免费短信猫SDK包SMS.DLL在64位系统上使用方法
- C# split字符串 根据1个或多个空格
- 弱省胡策 Round 3 Avalon【可并堆】【计算几何】
- servlet单实例多线程模式
- Windows Socket五种I/O模型详细介绍(精)
- eclipse项目启动后访问页面出现nojdk的错误
- 用队列实现图的拓扑排序
- Android:简易弹幕效果实现
- Lua: an extensible embedded language 部分翻译
- Java7中Switch语句支持String
- 黑马程序员---Java 线程