Codeforces #614 div.2 (A-E)
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;
}
}
}
}
#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);
}
每个岩浆点的对面或斜对面如果也有岩浆点,那么这两点之间就会形成障碍,统计这种障碍的数量
#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");
}
}
分析点集的特点,可以知道每一个数据点都在下标比它小的数据点的右上方,而且离下一个数据点的距离 大于 离第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;
}
最大S的方案必然是0-L都在一条链上,这条链上的数字是“山谷”型
推出状态转移方程
#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)的更多相关文章
- Codeforces #344 Div.2
Codeforces #344 Div.2 Interview 题目描述:求两个序列的子序列或操作的和的最大值 solution 签到题 时间复杂度:\(O(n^2)\) Print Check 题目 ...
- Codeforces #345 Div.1
Codeforces #345 Div.1 打CF有助于提高做题的正确率. Watchmen 题目描述:求欧拉距离等于曼哈顿距离的点对个数. solution 签到题,其实就是求有多少对点在同一行或同 ...
- Codeforces Beta Round #27 (Codeforces format, Div. 2)
Codeforces Beta Round #27 (Codeforces format, Div. 2) http://codeforces.com/contest/27 A #include< ...
- Codeforces#441 Div.2 四小题
Codeforces#441 Div.2 四小题 链接 A. Trip For Meal 小熊维尼喜欢吃蜂蜜.他每天要在朋友家享用N次蜂蜜 , 朋友A到B家的距离是 a ,A到C家的距离是b ,B到C ...
- codeforces #592(Div.2)
codeforces #592(Div.2) A Pens and Pencils Tomorrow is a difficult day for Polycarp: he has to attend ...
- codeforces #578(Div.2)
codeforces #578(Div.2) A. Hotelier Amugae has a hotel consisting of 1010 rooms. The rooms are number ...
- codeforces #577(Div.2)
codeforces #577(Div.2) A Important Exam A class of students wrote a multiple-choice test. There are ...
- codeforces #332 div 2 D. Spongebob and Squares
http://codeforces.com/contest/599/problem/D 题意:给出总的方格数x,问有多少种不同尺寸的矩形满足题意,输出方案数和长宽(3,5和5,3算两种) 思路:比赛的 ...
- Codeforces Round #614 (Div. 2) C - NEKO's Maze Game
题目链接:http://codeforces.com/contest/1293/problem/C 题目:给定一个 2*n的地图,初始地图没有岩浆,都可以走, 给定q个询问,每个询问给定一个点(x,y ...
随机推荐
- python随用随学-元类
python中的一切都是对象 按着我的逻辑走: 首先接受一个公理,「python中的一切都是对象」.不要问为什么,吉大爷(Guido van Rossum,python之父)人当初就是这么设计的,不服 ...
- 前端每日实战:60# 视频演示如何用纯 CSS 创作一块乐高积木
效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/qKKqrv 可交互视频 此视频是可 ...
- SuperBenchmarker一个用.NET编写的压测工具
0x01 前言 在这之前想必大家对ab(http)与abs(https)也有一些了解,我们今天不去看ab和abs,SuperBenchmarker(sb.exe)是一个压测工具,他是一个受Apache ...
- 趣谈编程史第3期-大器晚成的新晋流量Python发展史
写在前面 这篇博文主要介绍javaScript的发展史,根据作者在B站发布的同名视频的文案整理修改而成,对视频感兴趣的博友可访问https://www.bilibili.com/video/av860 ...
- 用户HTTP请求过程简单剖析
用户终端(如电脑浏览器)发起某个url请求,如http://www.baidu.com/1.jpg. 1.电脑首先会对www.baidu.com进行解析请求,获得域名对应的服务器IP. 2.电脑对服务 ...
- 在Tomcat上发布Web项目的方式
一. Tomcat的使用: 安装:解压压缩包即可 注意:安装目录不能有中文 目录结构: ①bin:可执行文件 ②conf:可执行文件 ③lib:依赖的jar包 ④logs:日志文件 ⑤:temp:临时 ...
- webstorm破解 2020 最新更新
KNBB2QUUR1-eyJsaWNlbnNlSWQiOiJLTkJCMlFVVVIxIiwibGljZW5zZWVOYW1lIjoiZ2hib2tlIiwiYXNzaWduZWVOYW1lIjoiI ...
- DIY 作品 及 维修 不定时更新
手机电池DIY充电宝 2块,优质手机电池加一个升压ic ,焊上一个 usb 母头.比买的强多了. 还能调压,最高调到24V 可以带白光焊台. 更换手机 SIM/SD 卡二合一 贴上高温胶带,吹下来. ...
- 1..Net平台的背景
一:.Net平台的背景 1. 2010之前 的PC时代的时候,互联网规模还不是特别庞大,以静态编译式语言为代表的JAVA和.Net没什么太大区别,.net以windows自居. 2. 2010年以JA ...
- 实验二 Samba服务器配置
实验二 实 验 基 本 信 息 实验名称:Samba服务器配置 实验时间: 年 月 日 实验地点: 实验目的: 了解Samba环境及协议 掌握Samba的工作原理 掌握主配置文件Samba.co ...