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 ...
随机推荐
- Stable Diffusion扩散模型
人像生成模型 1.模型理论基础 扩散模型(Diffusion Model): 1.1 Diffusion Model 原理 首先,Denoise Model 需要一个起始的噪声图像作为输入.这个噪声图 ...
- redis的基本命令,并用netty操作redis(不使用springboot或者spring框架)就单纯的用netty搞。
大家如果对使用netty搞这些http请求什么的感兴趣的,可以参观我自己创建的这个项目. nanshaws/nettyWeb: 复习一下netty,并打算做一个web项目出来 (github.com) ...
- Protobuf的使用,结合idea
安装Protobuf并配置idea Protocol Buffers(又名 protobuf)是 Google 的中立语言, 平台中立.可扩展的结构化数据序列化机制. 官网: https://gith ...
- hbase报错 ERROR: org.apache.hadoop.hbase.ipc.ServerNotRunningYetException: Server is not running yet
hbase报错:hbase shell能打开 网页也能打开 但是一执行命令就开始报错. 原因:hadoop的安全模式打开. 解决方法:关闭安全模式 ,再重新启动HBase就可以了. 具体的命令: 1. ...
- 数据库系列:业内主流MySQL数据中间件梳理
数据库系列:MySQL慢查询分析和性能优化 数据库系列:MySQL索引优化总结(综合版) 数据库系列:高并发下的数据字段变更 数据库系列:覆盖索引和规避回表 数据库系列:数据库高可用及无损扩容 数据库 ...
- bash shell笔记整理——less命令
less命令的作用 less和cat.more最大的差别在于不会一次性加载整个文件,速度比较快!另外less具备翻页功能,可以向上/向下翻页! 语法 less [选项] [文件名] *选项* *使用说 ...
- 华企盾DSC手机app登录不上常见处理方法
1.DSC服务器是否正常运行. 2.telnet外网是否通.(需要在程序与功能中添加telnet功能才能在cmd窗口用telnet命令 举例:telnet 172.17.2.20 5558) 3.其它 ...
- 有了Excel和PPT,为什么我们还需要数据可视化工具?
在当今信息时代,数据扮演着越来越重要的角色,而数据的可视化呈现正是一种强大的工具,能够帮助我们更好地理解和利用这些数据.虽然Excel和PPT在处理数据方面有着不可否认的作用,但在处理大规模.复杂数据 ...
- APP性能测试-客户端性能测试
https://blog.csdn.net/xiaomaoxiao336368/article/details/83547318
- 文心一言 VS 讯飞星火 VS chatgpt (168)-- 算法导论13.2 1题
一.用go语言,写出 RIGHT-ROTATE 的伪代码. 文心一言: 在计算机科学中,右旋转(RIGHT-ROTATE)是一种常见的操作,通常用于数组或链表.以下是一个使用Go语言实现右旋转的伪代码 ...