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. HTTP要点概述:十,内容协商

    一,内容协商(Content Negotiation) 同一个Web网站可能存在很多份相同内容的页面,比如英文版和中文版的Web页面,它们内容上相同,但是使用语言不同.比如大家进入英文版的google ...

  2. 利用JFreeChart生成多轴图表(7) (转自 JSP开发技术大全)

    利用JFreeChart生成多轴图表(7) (转自 JSP开发技术大全) 14.7 利用JFreeChart生成多轴图表 通过JFreeChart插件还可以生成拥有多个坐标轴的图表,简称多轴图表.在生 ...

  3. 推理集 —— death

    事故: 自杀: 他杀: 1. 跳楼 头向下死得比较快,没那么痛苦. 脚向下,不会立刻死亡,痛苦至极.死亡原因可能不是跳楼,而是失血过多而死 扑下去, 同头向下. 仰着跌下去,同头向下.. 跳楼最好头先 ...

  4. ubuntu16.04 查看系统可用内存

    free -m 查看内存情况    (单位MB) mem 行显示了从系统角度看来内存使用的情况, total是系统可用的内存大小, 数量上等于系统物理内存减去内核保留的内存. buffers和cach ...

  5. CodeForces 124C Prime Permutation (数论+贪心)

    题意:给定一个字符串,问你能不能通过重排,使得任意一个素数p <= 字符串长度n,并且 任意的 i <= 长度n/素数p,满足s[p] == s[p*i]. 析:很容易能够看出来,只要是某 ...

  6. Spring通过注解注入有参

    1.通过注解方式注入有参的构造函数 把@Autowired注解放在构造函数上方,在构造函数里写上需要注入的形参即可 2.通过XML配置文件方式定义有参构造函数

  7. git 删除本地仓库

    更新: 2017/06/27 修改格式,备注mac下的命令没测试过   windows: rm .git/ mac: sudo rm -rf .git/ 没验证

  8. P3482 [POI2009]SLO-Elephants

    传送门 首先,交换关系肯定是构成一个环的时候最优 如果这个环是自环,不用交换了 如果环的大小为2,直接交换便是 否则的话,我们可以用环里最小的点最为交换媒介,然后去和其他交换直到到达正确的位置,那么环 ...

  9. array_column() 函数[二维数组转为一维数组]

    array_column() 函数 输出数组中某个键值的集合[二维数组转为一位数组] <?php // 表示由数据库返回的可能记录集的数组 $a = array( array( 'id' =&g ...

  10. git merge合并时遇上refusing to merge unrelated histories的解决方案

    如果git merge合并的时候出现refusing to merge unrelated histories的错误,原因是两个仓库不同而导致的,需要在后面加上--allow-unrelated-hi ...