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. Safari配置WebApp----添加启动图和桌面图标让你的WebApp在ios设备上体验如原生一样

    现在很多开发者的Web应用程序的设计样式和交互类似本机应用程序,例如,它的缩放比例适合iOS上的整个屏幕.当用户将其添加到主屏幕时,您可以通过使其看起来像本机应用程序一样,在iOS上为您的Web应用程 ...

  2. 读《Java并发编程的艺术》学习笔记(一)

    接下来一个系列,是关于<Java并发编程的艺术>这本书的读书笔记以及相关知识点,主要是为了方便日后多次复习和防止忘记.废话不多说,直接步入主题: 第1章  并发编程的挑战 并发编程的目的是 ...

  3. TP5使用Redis处理电商秒杀

    本篇文章介绍了ThinkPHP使用Redis实现电商秒杀的处理方法,具有一定的参考价值,希望对学习ThinkPHP的朋友有帮助! TP5使用Redis处理电商秒杀 1.首先在TP5中创建抢购活动所需要 ...

  4. TARS基金会:构建微服务开源生态

    导语 在20世纪60至70年代,软件开发人员通常在大型机和小型机上使用单体架构进行软件开发,没有一个应用程序能够满足大多数最终用户的需求.垂直行业使用的软件代码量更小,与其他应用程序的接口更简单,而可 ...

  5. 关于JS的数据类型与转化(自动与强制)

    在我们谈到JS的数据类型转化时,一定会知道分为自动转化和强制转化两种方式吧,通俗来讲,自动就是在某种条件下,电脑浏览器自己会把其他类型的数据转化为相应的数据类型,而强制则是咋们程序员应该手动来做的了, ...

  6. vue基础回顾 router

    vue-router 1. 底层原理 hash 或者h5 histroy(有兼容性) 2. 使用的时候Vue需要引入VueRouter Vue.use(VueRouter) //VueRouter 底 ...

  7. 在ES批量插入数据超时时自动重试

    当我们使用ES批量插入数据的时候,一般会这样写代码: from elasticsearch import Elasticsearch,helpers es =Elasticsearch(hosts=[ ...

  8. 【Weiss】【第03章】练习3.15:自调整链表

    [练习3.15] a.写出自调整表的数组实现.自调整表如同一个规则的表,但是所有的插入都在表头进行. 当一个元素被Find访问时,它就被移到表头而并不改变其余的项的相对顺序. b.写出自调整表的链表实 ...

  9. 【Weiss】【第03章】链表例程的一些修改

    主要是,感觉原来的链表例程通过Node的分配形成了链表,但是没有自动消除Node的办法比较危险,一旦在clear()之前把链表赋了其它值就内存泄漏了. 所以改了析构函数,自动清理分配出来的内存.既然改 ...

  10. 【TIJ4】第三章全部习题

    题目都相当简单没啥说的直接放代码就行了... 3.1 package ex0301; //[3.1]使用“简短的”和正常的打印语句来写一个程序 import static java.lang.Syst ...