A  ConneR and the A.R.C. Markland-N

 #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inc(i, l, r) for (int i = l; i <= r; i++) int t, n, s, k, x; int main() {
cin >> t;
while (t--) {
cin >> n >> s >> k;
map<int, int> m;
inc(i, , k) {
cin >> x;
m[x] = ;
}
inc(del, , k) {
if ((s + del <= n && m[s + del] == ) ||
(s - del >= && m[s - del] == )) {
cout << del << "\n";
break;
}
}
}
}

B  JOE is on TV!

 #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inc(i, l, r) for (int i = l; i <= r; i++) int n;
double r; int main() {
cin >> n;
for (int i = n; i >= ; i--) r += 1.0 / i;
printf("%.12f", r);
}

C  NEKO's Maze Game

每个岩浆点的对面或斜对面如果也有岩浆点,那么这两点之间就会形成障碍,统计这种障碍的数量

 #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inc(i, l, r) for (int i = l; i <= r; i++) const int maxn = 1e6 + ; int a[][maxn];
int n, q, k, x, y; int main() {
cin >> n >> q;
inc(i, , q - ) {
cin >> x >> y;
x--;
if (a[x][y] == ) {
a[x][y] = ;
inc(del, -, ) if (a[ - x][y + del] == ) k++;
} else {
a[x][y] = ;
inc(del, -, ) if (a[ - x][y + del] == ) k--;
}
if(k) puts("NO");
else puts("YES");
}
}

D  Aroma's Search

分析点集的特点,可以知道每一个数据点都在下标比它小的数据点的右上方,而且离下一个数据点的距离 大于 离第0个数据点的距离。

枚举Aroma从哪个点出发;先往第0个数据点走,然后尽可能往右上走

 #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inc(i, l, r) for (int i = l; i <= r; i++) const int maxn = 1e6 + ; ll a0, b0, ax, bx, ay, by;
ll xs, ys, t; ll dx[maxn], dy[maxn];
ll dis[maxn]; int res; int main() {
cin >> a0 >> b0 >> ax >> ay >> bx >> by;
cin >> xs >> ys >> t;
ll tx = a0, ty = b0;
int top;
for (top = ; tx <= 2e16 && ty <= 2e16; top++) {
dx[top] = tx, dy[top] = ty;
tx = tx * ax + bx, ty = ty * ay + by;
}
inc(i, , top - ) dis[i] = dx[i] - dx[] + dy[i] - dy[];
inc(i, , top - ) {
ll tmp = t - abs(xs - dx[i]) - abs(ys - dy[i]);
if (tmp < ) continue;
int tot = ;
if (tmp <= dis[i]) {
tot = i - (lower_bound(dis, dis + top, dis[i] - tmp) - dis) + ;
} else {
tot = upper_bound(dis + i + , dis + top, tmp - dis[i]) - dis;
}
res = max(res, tot);
}
cout << res;
}

E  Xenon's Attack on the Gangs

最大S的方案必然是0-L都在一条链上,这条链上的数字是“山谷”型

推出状态转移方程

dp[u][v] = sub[u][v] * sub[v][u] + max(solve(par[v][u], v), solve(par[u][v], u));
 #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inc(i, l, r) for (int i = l; i <= r; i++)
#define pb push_back const int maxn = 3e3 + ;
vector<int> edge[maxn];
int n, u, v;
int sub[maxn][maxn], par[maxn][maxn];
ll dp[maxn][maxn], res; int root; int dfs(int x, int p) {
sub[root][x] = ;
for (int i = ; i < edge[x].size(); i++) {
if (edge[x][i] != p) {
par[root][edge[x][i]] = x;
sub[root][x] += dfs(edge[x][i], x);
}
}
return sub[root][x];
} ll solve(int u, int v) {
if (u == v) return ;
if (dp[u][v]) return dp[u][v];
return dp[u][v] = sub[u][v] * sub[v][u] +
max(solve(par[v][u], v), solve(par[u][v], u));
} int main() {
cin >> n;
inc(i, , n - ) {
cin >> u >> v;
edge[u].pb(v);
edge[v].pb(u);
}
inc(i, , n) {
root = i;
dfs(root, -);
}
inc(i, , n) inc(j, , n) {
res = max(res, solve(i, j));
}
printf("%lld\n", res);
}

Codeforces #614 div.2 (A-E)的更多相关文章

  1. Codeforces #344 Div.2

    Codeforces #344 Div.2 Interview 题目描述:求两个序列的子序列或操作的和的最大值 solution 签到题 时间复杂度:\(O(n^2)\) Print Check 题目 ...

  2. Codeforces #345 Div.1

    Codeforces #345 Div.1 打CF有助于提高做题的正确率. Watchmen 题目描述:求欧拉距离等于曼哈顿距离的点对个数. solution 签到题,其实就是求有多少对点在同一行或同 ...

  3. Codeforces Beta Round #27 (Codeforces format, Div. 2)

    Codeforces Beta Round #27 (Codeforces format, Div. 2) http://codeforces.com/contest/27 A #include< ...

  4. Codeforces#441 Div.2 四小题

    Codeforces#441 Div.2 四小题 链接 A. Trip For Meal 小熊维尼喜欢吃蜂蜜.他每天要在朋友家享用N次蜂蜜 , 朋友A到B家的距离是 a ,A到C家的距离是b ,B到C ...

  5. codeforces #592(Div.2)

    codeforces #592(Div.2) A Pens and Pencils Tomorrow is a difficult day for Polycarp: he has to attend ...

  6. codeforces #578(Div.2)

    codeforces #578(Div.2) A. Hotelier Amugae has a hotel consisting of 1010 rooms. The rooms are number ...

  7. codeforces #577(Div.2)

    codeforces #577(Div.2) A  Important Exam A class of students wrote a multiple-choice test. There are ...

  8. codeforces #332 div 2 D. Spongebob and Squares

    http://codeforces.com/contest/599/problem/D 题意:给出总的方格数x,问有多少种不同尺寸的矩形满足题意,输出方案数和长宽(3,5和5,3算两种) 思路:比赛的 ...

  9. Codeforces Round #614 (Div. 2) C - NEKO's Maze Game

    题目链接:http://codeforces.com/contest/1293/problem/C 题目:给定一个 2*n的地图,初始地图没有岩浆,都可以走, 给定q个询问,每个询问给定一个点(x,y ...

随机推荐

  1. c语言之单向链表

    0x00 什么是链表 链表可以说是一种最为基础的数据结构了,而单向链表更是基础中的基础.链表是由一组元素以特定的顺序组合或链接在一起的,不同元素之间在逻辑上相邻,但是在物理上并不一定相邻.在维护一组数 ...

  2. (原)人体姿态识别PyraNet

    转载请注明出处: https://www.cnblogs.com/darkknightzh/p/12424767.html 论文: Learning Feature Pyramids for Huma ...

  3. sql05

    1.Ado.net Ado.net是一组由微软提供的使用C#操作数据库的类库 2.连接 首先引入: using System.Data.SqlClient; 需要使用连接字符串进行连接 using S ...

  4. 一步步打造自己的纯CSS单标签图标库

    图标作为网页设计中的一部分,其在凸显网页重要元素特性,视觉交互.引导以及网页装饰等充当的角色作用举足轻重.由于图标普遍具有尺寸小的特点,在项目实践时不宜将每个图标作为单个图片元素进行加载,这会增加Ht ...

  5. objectarx 填充的分割

    主要思路:找到填充边界集合:vecBo,然后把面积最大的边界找出来:bo1,用分割曲线和bo1通过boundary命令构成两个新的最大封闭边界,左边的记为 boLeft(红色部分),右边的记为boRi ...

  6. 17-Java-文件上传报错(commons-fileupload包和commons-io包不支持JDK版本:UnsupportedClassVersionError: org/apache/commons/io/IOUtils : Unsupported major.minor version 52.0)

    文件上传报错(commons-fileupload包和commons-io包不支持JDK版本) 这个bug可把我弄惨了!!!我代码是想通过写个文件上传,我写的文件上传需要用到commons-fileu ...

  7. 这样阅读STM32参考手册更高效

    <STM32F103xxx参考手册>不需要全部阅读——没有时间的.建议选读,但是前几章必读.存储器和总线架构.电源控制.备份寄存器.复位和时钟控制,通用和复用功能I/O,中断和时间等等前几 ...

  8. IRM3800 红外遥控器解码 linux驱动

    这一次还是接在 Cemera 上.用 中断引脚 EINT20 也就是 GPG12. 之前焊的 51 板子上有一个红外接收器. 请注意了,是 标准的 NEC 码规范:首次发送的是9ms的高电平脉冲,其后 ...

  9. 群辉DS418play体验+经验分享

    群辉DS418play体验+经验分享     群辉DS418play体验+经验分享   购买初衷 近期百度网盘到期,我又需要重复下载很多资源(游戏.电影.毛片),下载没速度&下完没空间怎么办? ...

  10. java实现QQ、微信、轰炸机,撩妹,抖图功能,轻松自如

    今天交大家一个很牛的功能,让你朋友服你,他不扶你你来找我. 打游戏被骂,骂不过你来找我,我们有神器,直到他怕了为止. 废话少说,代码如下,动手,干就完了 乞丐版如下 参考连接:Java实现QQ微信轰炸 ...