Codeforces Round #689 (Div. 2, based on Zed Code Competition) 个人题解
1461A. String Generation
void solve() {
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; ++i)
cout << (char)(i < k ? 'a' : 'a' + (i - k) % 3);
cout << endl;
}
1461B.Find the Spruce
DP,从下往上推
const int N = 500 + 10;
char s[N][N];
int dp[N][N];
void solve() {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; ++i)
cin >> s[i] + 1;
int ans = 0;
for (int i = n; i; i -= 1)
for (int j = m; j; j -= 1) {
dp[i][j] = 0;
if (s[i][j] == '*') {
if (i < n and j > 1 and j < m)
dp[i][j] = 1 + min({dp[i + 1][j - 1], dp[i + 1][j],
dp[i + 1][j + 1]});
else
dp[i][j] = 1;
}
ans += dp[i][j];
}
cout << ans << endl;
}
1461C. Random Events
贪心
int a[N];
void solve() {
cout << fixed << setprecision(6);
int n, q;
cin >> n >> q;
for (int i = 1; i <= n; ++i)
cin >> a[i];
int m = n;
while (a[m] == m and m)
m--;
double ans = 1, p;
for (int i = 1, r; i <= q; i += 1) {
cin >> r >> p;
if (r >= m)
ans *= 1 - p;
}
if (!m)
cout << 1.0 << endl;
else
cout << 1 - ans << endl;
}
1461D.Divide and Summarize
贪心先把能找到的都找出来, \(O(nlog^2n)\)
int a[N];
ll sum[N];
void solve() {
cout << fixed << setprecision(6);
int n, m, q;
cin >> n >> m;
for (int i = 1; i <= n; ++i)
cin >> a[i];
sort(a + 1, a + 1 + n);
// 前缀和
for (int i = 1; i <= n; ++i)
sum[i] = sum[i - 1] + a[i];
set<ll> s;
// 用新写法
function<void(int, int)> DFS = [&](int L, int R) {
s.insert(sum[R] - sum[L - 1]);
if (a[L] == a[R])
return;
int M = upper_bound(a + L, a + R + 1, (a[L] + a[R]) / 2) - a;
DFS(L, M - 1),DFS(M, R);
};
DFS(1, n);
for (int i = 1; i <= m; ++i) {
cin >> q;
cout << (s.count(q) ? "Yes\n" : "No\n");
}
}
Codeforces Round #689 (Div. 2, based on Zed Code Competition) 个人题解的更多相关文章
- Codeforces Round #689 (Div. 2, based on Zed Code Competition) E. Water Level (贪心好题)
题意:你在一家公司工作\(t\)天,负责给饮水机灌水,饮水机最初有\(k\)升水,水的范围必须要在\([l,r]\)内,同事每天白天都会喝\(x\)升水,你在每天大清早可以给饮水机灌\(y\)升水,问 ...
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals)
Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) 说一点东西: 昨天晚上$9:05$开始太不好了,我在学校学校$9:40$放 ...
- Codeforces Round #500 (Div. 2) [based on EJOI]
Codeforces Round #500 (Div. 2) [based on EJOI] https://codeforces.com/contest/1013 A #include<bit ...
- Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2)
Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2) #include <bits/stdc++ ...
- Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics)
A. Even Subset Sum Problem 题意 给出一串数,找到其中的一些数使得他们的和为偶数 题解 水题,找到一个偶数或者两个奇数就好了 代码 #include<iostream& ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2)
A - Forgetting Things 题意:给 \(a,b\) 两个数字的开头数字(1~9),求使得等式 \(a=b-1\) 成立的一组 \(a,b\) ,无解输出-1. 题解:很显然只有 \( ...
- (AB)Codeforces Round #528 (Div. 2, based on Technocup 2019 Elimination Round
A. Right-Left Cipher time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861C Did you mean...【字符串枚举,暴力】
C. Did you mean... time limit per test:1 second memory limit per test:256 megabytes input:standard i ...
- Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861B Which floor?【枚举,暴力】
B. Which floor? time limit per test:1 second memory limit per test:256 megabytes input:standard inpu ...
- Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861A k-rounding【暴力】
A. k-rounding time limit per test:1 second memory limit per test:256 megabytes input:standard input ...
随机推荐
- 【结对作业】 第一周 | 学习体会day05
实现了单条地铁线路的直达 进行了页面的优化,实现了侧边栏功能 并且对第二天(今天)的任务进行了规划.
- 银河麒麟V10(飞腾ARM CPU)安装KVM踩坑记
服务器配置信息 品牌:GreetWall CPU:飞腾FT-2000+/64 64bit 操作系统:Linux-4.19.90-24.4.v2101.ky10.aarch64-with-kylin-1 ...
- skywalking插件工作原理剖析
1. 官方插件二次开发 前面在介绍skywalking-agent目录时,提到了它有一个插件目录,并支持动态的开发插件.其实skywalking默认已经提供大部分框架的插件了,一般情况下不需要额外开发 ...
- ElasticSearch之Search settings
相关参数 indices.query.bool.max_clause_count 本参数当前已失效. search.max_buckets 本参数用于控制在单个响应中返回的聚合的桶的数量. 默认值为6 ...
- startx详解
linux下startx命令详解 用途 初始化一个 X 会话. 语法 startx [ -d Display:0 ] [ -t | -w ] [ -x Startup | [ -r Resources ...
- PythonAnywhere 部署Flask项目
一. 注册账号 官网:https://www.pythonanywhere.com/ 二. 将GitHub上的项目发送至PythonAnywhere 三.配置环境及运行 git clone https ...
- 【wing】一款轻量快捷的团队开发工具
导航 开源地址:[Github] & [Gitee] 新手使用 更多命令 开发指南 说明 wing是一个代码同步管理工具类似repo,具有以下特性: 支持Winddows .Linux .Ma ...
- 面试官:请列举 Spring 的事务会失效的场景
在日常工作中,如果对 Spring 的事务管理功能使用不当,则会造成 Spring 事务不生效的问题.而针对 Spring 事务不生效的问题,也是在跳槽面试中被问的比较频繁的一个问题. 今天,我们就一 ...
- 【API 进阶之路】做 OCR 文字识别,谁说必须要有 AI 工程师?
摘要:有些功能还真不能光凭自己的直觉和认识,来自一线的声音才是最真实的用户需求.比方说名片录入的需求. 在公司技术委员会副主席这个位置上干了有几个月了,期间,我一方面给研发团队整理各种文档资料,做技术 ...
- 如何使用参数化查询提高Cypher查询的性能
摘要:在DBMS中,参数化查询被视为一种有效预防SQL注入攻击的手段. 本文分享自华为云社区<使用参数化查询提高Cypher查询的性能:以华为云图引擎GES为例>,作者: 蜉蝣与海. 在D ...