Codeforces #418(Div 2)
来源:互联网 发布:ssh无法连接linux 编辑:程序博客网 时间:2024/06/15 05:57
Codeforces #418(Div 2)
C. An impassioned circulation of affection
预处理
#include <bits/stdc++.h>using namespace std;const int MAXN = 1505;int n, q;char str[MAXN];int A[MAXN][26];int pos[MAXN], top = 0;void init(){ for (int i = 1; i <= n; i++) { for (int j = 0; j < 26; j++) { top = 0; memset(pos, 0, sizeof pos); for (register int k = 1; k <= n; k++) if (str[k]-'a' == j) pos[k] = 1; int l = 1, len = 0, t = 0, ans = 0; for (register int k = 1; k <= n; k++) { len += 1-pos[k], t++; while (len > i) len -= 1-pos[l], t--, l++; ans = max(ans, t); } A[i][j] = ans; } }}int main(){ scanf("%d", &n); scanf("%s", str+1); init(); scanf("%d", &q); for (int i = 1; i <= q; i++) { int u; char c; scanf("%d %c", &u, &c); printf("%d\n", A[u][c-'a']); } return 0;}
D. An overnight dance in discotheque
大力贪心,不会证明。
#include <bits/stdc++.h>using namespace std;const int MAXN = 1005;const double eps = 1e-9;struct circ { int x, y, r; friend bool operator < (const circ &a, const circ &b) { return a.r > b.r; }} c[MAXN], A[MAXN], B[MAXN];int n;int ta = 0, tb = 0;int main(){ scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d%d%d", &c[i].x, &c[i].y, &c[i].r); sort(c+1, c+n+1); long long ans = 0; for (int i = 1; i <= n; i++) { int tmsa = 0, tmsb = 0; for (int j = 1; j <= ta; j++) if ((long long)(A[j].x-c[i].x)*(A[j].x-c[i].x)+(long long)(A[j].y-c[i].y)*(A[j].y-c[i].y) <= (long long)(A[j].r-c[i].r)*(A[j].r-c[i].r)) tmsa++; for (int j = 1; j <= tb; j++) if ((long long)(B[j].x-c[i].x)*(B[j].x-c[i].x)+(long long)(B[j].y-c[i].y)*(B[j].y-c[i].y) <= (long long)(B[j].r-c[i].r)*(B[j].r-c[i].r)) tmsb++; if ((tmsa&1)==0) A[++ta] = c[i], ans += (long long)c[i].r*c[i].r; else if ((tmsb&1)==0) B[++tb] = c[i], ans += (long long)c[i].r*c[i].r; else A[++ta] = c[i], ans -= (long long)c[i].r*c[i].r; } printf("%.10f\n", ans*M_PI); return 0;}
阅读全文
0 0
- Codeforces #418(Div 2)
- Codeforces Round #418 (Div. 2)
- Codeforces Round #418 (Div. 2)
- Codeforces Round #418 (Div. 2)
- Codeforces Round #418 (Div. 2)
- Codeforces Round #418 (Div. 2)
- Codeforces Round #418 (Div. 2)
- Codeforces Round #418 (Div. 2) C
- Codeforces Round #418 (Div. 2) 题解 ABC
- Codeforces Round#418 (Div.2) ABC
- Codeforces Round #418 (Div. 2) ABCD
- Codeforces Round #418 (Div. 2) Codeforces 814A-D
- codeForces #140 div 2
- codeforces #149 div 2
- Codeforces #154 div 2
- Codeforces 156 div.2
- codeforces 167 div 2
- codeforces #176 div.2
- 记2017第八届蓝桥杯决赛—北京三日游
- 使用 jsoup 对 HTML 文档进行解析和操作
- python中文字符串居中/中文居中python/python汉字字符串居中:手撕比方法好用
- nessus更新插件经验
- php使用openssl来实现非对称加密
- Codeforces #418(Div 2)
- 进程间通信---信号量
- 侧测代码量
- ubuntu下搭建vsftpd,实现从外网访问到内网ftp服务器
- 使用nginx与nginx-rtmp-module搭建流媒体服务器
- 求平均成绩
- handler消息处理机制
- 大数据01_hadoop入门基础知识
- Map转json遇到一些问题