HDU多校Round 5
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的更多相关文章
- HDU多校Round 8
Solved:2 rank:141 D. Parentheses Matrix n,m有一个小于6的时候是一种构造方法 答案是n + (m - 2) / 2 (n > m) 都大于6的时候 可以 ...
- HDU多校Round 7
Solved:2 rank:293 J. Sequense 不知道自己写的什么东西 以后整数分块直接用 n / (n / i)表示一个块内相同n / i的最大i #include <bits/s ...
- HDU多校Round 6
Solved:2 rank:452 I. Werewolf 没有铁人 找铁狼 如果一个环中只有一条狼人边那个人就是铁狼 说铁狼是好人的人也是铁狼 #include <bits/stdc++.h& ...
- HDU多校Round 4
Solved:3 rank:405................................. B. Harvest of Apples 知道了S(n,m) 可以o(1)的求S(n - 1, m ...
- HDU多校Round 3
Solved:4 rank:268 C. Dynamic Graph Matching 状压DP一下 #include <stdio.h> #include <algorithm& ...
- HDU多校Round 1
Solved:5 rank:172 A.Maximum Multiple #include <stdio.h> #include <algorithm> #include &l ...
- hdu 5667 BestCoder Round #80 矩阵快速幂
Sequence Accepts: 59 Submissions: 650 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...
- hdu 5643 BestCoder Round #75
King's Game Accepts: 249 Submissions: 671 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 6 ...
- hdu 5641 BestCoder Round #75
King's Phone Accepts: 310 Submissions: 2980 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
随机推荐
- HDU5294 Tricks Device(最大流+SPFA) 2015 Multi-University Training Contest 1
Tricks Device Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) To ...
- easyUI datagrid 前端真分页
前文再续,书接上一回.easyUI datagrid 前端假分页 http://blog.csdn.net/leftfist/article/details/43164977 真分页是easyUI d ...
- Minimizing Maximizer
题意: 最少需要多少个区间能完全覆盖整个区间[1,n] 分析: dp[i]表示覆盖[1,i]最少需要的区间数,对于区间[a,b],dp[b]=min(dp[a...b-1])+1;用线段树来维护区间最 ...
- 基于ASP.NET MVC的快速开发平台,给你的开发一个加速度!
基于ASP.NET MVC的快速开发平台,给你的开发一个加速度! bingo炸了 2017/4/6 11:07:21 阅读(37) 评论(0) 现在的人做事情都讲究效率,最好能达到事半功倍那种效果,软 ...
- [Codeforces 140C] New Year Snowmen
[题目链接] https://codeforces.com/problemset/problem/140/C [算法] 显然 , 我们每次应优先考虑数量多的雪球 将雪球个数加入堆中 , 每次取出数量前 ...
- ssh验证和端口转发
ssh 服务登录验证 ssh 服务登录验证方式: 用户/ 口令 基于密钥 基于用户和口令登录验证 客户端发起ssh请求,服务器会把自己的公钥发送给用户 用户会根据服务器发来的公钥对密码进行加密 加密后 ...
- [SDOI2011]消防(单调队列,树的直径,双指针)
消防 2011年 时间限制: 2 s 空间限制: 256000 KB 题目等级 : 大师 Master 题目描述 Description 某个国家有n个城市,这n个城市中任意两个都连通且有 ...
- O(1)的快速乘
那么 有位神仙已经说了O(1)的算法(当然不是我) 这是一种骚操作 直接放代码了啊 inline LL mul(LL a,LL b,LL Mod){ LL lf = a * ( b >> ...
- JS 实现PDF文件打印
function PdfPrint() { bdhtml = window.document.body.innerHTML; sprnstr = "<!-- ...
- php 页面展示
php 页面展示 复杂逻辑. 段落注释