Solved:3

rank:71

E. Everything Has Changed

#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0); int main()
{
int T;
scanf("%d", &T);
while(T--)
{
int m; double R;
scanf("%d%lf", &m, &R); double ans = 2.0 * PI * R;
for(int i = ; i <= m; i++)
{
double x, y, r;
scanf("%lf%lf%lf", &x, &y, &r); double dis = sqrt(x * x + y * y);
if(dis + r < R || dis - r >= R) continue; double c1 = acos((r * r + dis * dis - R * R) / (2.0 * dis * r));
ans += c1 * 2.0 * r;
double c2 = acos((R * R + dis * dis - r * r) / (2.0 * dis * R));
ans -= c2 * 2.0 * R;
}
printf("%.20lf\n", ans);
}
return ;
}

G. Glad You Came

#include <bits/stdc++.h>
using namespace std;
typedef unsigned int ui;
typedef long long ll; ui x, y, z;
ui sui()
{
x ^= x << ;
x ^= x >> ;
x ^= x << ;
x ^= x >> ;
ui p = x ^ (y ^ z);
x = y;
y = z;
z = p;
return z;
} ll zx[];
int lz[]; void pushup(int rt)
{
zx[rt] = min(zx[rt << ], zx[rt << | ]);
} void pushdown(int rt)
{
if(lz[rt])
{
lz[rt << ] = max(lz[rt << ], lz[rt]);
lz[rt << | ] = max(lz[rt << | ], lz[rt]);
zx[rt << ] = max(zx[rt << ], (ll)lz[rt << ]);
zx[rt << | ] = max(zx[rt << | ], (ll)lz[rt << | ]);
lz[rt] = ;
}
} void build(int l, int r, int rt)
{
if(l == r)
{
zx[rt] = lz[rt] = ;
return;
}
zx[rt] = lz[rt] = ; int m = l + r >> ;
build(l, m, rt << );
build(m + , r, rt << | );
} void update(int ql, int qr, int v, int l, int r, int rt)
{
if(zx[rt] >= v) return;
if(ql <= l && qr >= r)
{
lz[rt] = max(lz[rt], v);
zx[rt] = max(zx[rt], (ll)v);
return;
} pushdown(rt);
int m = l + r >> ;
if(ql <= m) update(ql, qr, v, l, m, rt << );
if(qr > m) update(ql, qr, v, m + , r, rt << | );
pushup(rt);
} ll query(int l, int r, int rt)
{
if(l == r) return 1LL * (ll)l * zx[rt];
pushdown(rt); ll res = ;
int m = l + r >> ;
res ^= query(l, m, rt << );
res ^= query(m + , r, rt << | );
return res;
} int main()
{
int T;
scanf("%d", &T);
while(T--)
{
int n, m;
cin>>n>>m>>x>>y>>z;
int l, r, v; build(, n, );
for(int i = ; i <= m; i++)
{
ui f1 = sui(), f2 = sui(), f3 = sui();
l = min(f1 % n + , f2 % n + );
r = max(f1 % n + , f2 % n + );
v = f3 % ( << );
update(l, r, v, , n, );
}
printf("%lld\n", query(, n, ));
}
return ;
}

H. Hills And Valleys

构造一个0-9的数组 每次枚举翻转哪两个数就一共45次

然后把两个数组跑一个lcs 枚举翻转的那个数组可以多次匹配

#include <bits/stdc++.h>
using namespace std; char s[];
int a[];
int b[];
int dp[][];
int l[][];
int r[][];
int n, cnt, nl, nr;
int ans, ansl, ansr; void solve(int len)
{
for(int i = ; i <= len; i++) dp[][i] = ;
for(int i = ; i <= n; i++)
{
for(int j = ; j <= len; j++)
{
dp[i][j] = dp[i - ][j];
l[i][j] = l[i - ][j];
r[i][j] = r[i - ][j];
if(a[i] == b[j])
{
dp[i][j]++;
if(j == nl && l[i][j] == ) l[i][j] = i;
if(j == nr) r[i][j] = i;
} if(dp[i][j - ] > dp[i][j])
{
dp[i][j] = dp[i][j - ];
l[i][j] = l[i][j - ];
r[i][j] = r[i][j - ];
}
}
}
} int main()
{
int T;
scanf("%d", &T);
while(T--)
{
scanf("%d", &n);
scanf("%s", s);
int zx = , zd = ;
for(int i = ; i <= ; i++) b[i] = i - ;
for(int i = ; i < n; i++)
{
a[i + ] = s[i] - '';
zx = min(zx, a[i + ]);
zd = max(zd, a[i + ]);
} solve();
ansl = ;
ansr = ;
ans = dp[n][];
for(int i = zx; i <= zd; i++)
{
for(int j = zx; j < i; j++)
{
cnt = ;
for(int a = ; a <= j; a++) b[++cnt] = a;
nl = cnt + ;
for(int a = i; a >= j; a--) b[++cnt] = a;
nr = cnt;
for(int a = i; a < ; a++) b[++cnt] = a;
solve(cnt); if(dp[n][cnt] > ans && l[n][cnt] && r[n][cnt])
{
ans = dp[n][cnt];
ansl = l[n][cnt];
ansr = r[n][cnt];
}
}
}
printf("%d %d %d\n", ans, ansl, ansr);
}
return ;
}

HDU多校Round 5的更多相关文章

  1. HDU多校Round 8

    Solved:2 rank:141 D. Parentheses Matrix n,m有一个小于6的时候是一种构造方法 答案是n + (m - 2) / 2 (n > m) 都大于6的时候 可以 ...

  2. HDU多校Round 7

    Solved:2 rank:293 J. Sequense 不知道自己写的什么东西 以后整数分块直接用 n / (n / i)表示一个块内相同n / i的最大i #include <bits/s ...

  3. HDU多校Round 6

    Solved:2 rank:452 I. Werewolf 没有铁人 找铁狼 如果一个环中只有一条狼人边那个人就是铁狼 说铁狼是好人的人也是铁狼 #include <bits/stdc++.h& ...

  4. HDU多校Round 4

    Solved:3 rank:405................................. B. Harvest of Apples 知道了S(n,m) 可以o(1)的求S(n - 1, m ...

  5. HDU多校Round 3

    Solved:4 rank:268 C. Dynamic Graph Matching  状压DP一下 #include <stdio.h> #include <algorithm& ...

  6. HDU多校Round 1

    Solved:5 rank:172 A.Maximum Multiple #include <stdio.h> #include <algorithm> #include &l ...

  7. hdu 5667 BestCoder Round #80 矩阵快速幂

    Sequence  Accepts: 59  Submissions: 650  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536 ...

  8. hdu 5643 BestCoder Round #75

    King's Game  Accepts: 249  Submissions: 671  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 6 ...

  9. hdu 5641 BestCoder Round #75

    King's Phone  Accepts: 310  Submissions: 2980  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: ...

随机推荐

  1. NSoup解析处理Html

    以前在做网页静态生成的时候,使用正则表达式分析提取网页链接.最近搜索了解到java有个Jsoup解析网页,对应.net有个nsoup.处理网页非常好用. Document doc = NSoupCli ...

  2. Xubuntu 计划从 19.04 版本开始停止提供 32 位安装镜像(XDE/LXQt的 Lubuntu 成为了目前唯一仍然提供 32 位安装镜像的 Ubuntu 桌面发行版)

    Ubuntu 17.10 以及其他许多 *buntu 衍生品都已在今年早些时候停止提供 32 位安装镜像.但其中有一个依然坚持提供适用于 i386 架构的镜像,它就是 Xubuntu,但现在 Xubu ...

  3. 阿里Java开发规约笔记

    借助阿里开发规约,回顾一下Java开发编码基础方面的知识,结合自己使用中遇到的问题,记录一下规约中以前翻过的错.有共鸣的问题. 1.覆写方法时要加上@Override注解.重写一个类型T的equals ...

  4. 51Nod 1450 闯关游戏 —— 期望DP

    题目:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1450 期望DP: INF 表示这种情况不行,转移时把不行的概率也转 ...

  5. bzoj1415 [Noi2005]聪聪和可可——概率期望

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1415 看博客:http://www.cnblogs.com/Narh/p/9206642.h ...

  6. ssh使用秘钥文件连接提示WARNING: UNPROTECTED PRIVATE KEY FILE!(转载)

    转自:http://www.01happy.com/ssh-unprotected-private-key-file/ 在centos 6.4下使用ssh连接远程主机时,用的是另外一个密钥,需要用-i ...

  7. Android 属性系统 Property service 设定分析 (转载)

    转自:http://blog.csdn.net/andyhuabing/article/details/7381879 Android 属性系统 Property service 设定分析 在Wind ...

  8. 【WIP_S2】递归

    创建: 2018/01/14    递归  定义  自己召唤自己  通用形式  if (基本情况A的处理) {     ...     return 值A  } else if (基本情况B的处理) ...

  9. 0629-TP整理四(create(),success(),error(),U())

    create()-前提:表单中name的值要与数据库中的字段一一匹配 可直接获取表单数据进行操作: 作用:将数据库中没有的字段在数组中去除. PHP中添加的语法如下: success()和error( ...

  10. c++ isdigit函数

    函数名:isdigit 函数所需头文件:#include<cstdio> 函数格式:isdigit(字符) 函数作用:判断括号内是否为1~9的数字. 例:isdigit(4) 就是true ...