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) 个人题解的更多相关文章

  1. Codeforces Round #689 (Div. 2, based on Zed Code Competition) E. Water Level (贪心好题)

    题意:你在一家公司工作\(t\)天,负责给饮水机灌水,饮水机最初有\(k\)升水,水的范围必须要在\([l,r]\)内,同事每天白天都会喝\(x\)升水,你在每天大清早可以给饮水机灌\(y\)升水,问 ...

  2. Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals)

    Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) 说一点东西: 昨天晚上$9:05$开始太不好了,我在学校学校$9:40$放 ...

  3. Codeforces Round #500 (Div. 2) [based on EJOI]

    Codeforces Round #500 (Div. 2) [based on EJOI] https://codeforces.com/contest/1013 A #include<bit ...

  4. 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++ ...

  5. Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics)

    A. Even Subset Sum Problem 题意 给出一串数,找到其中的一些数使得他们的和为偶数 题解 水题,找到一个偶数或者两个奇数就好了 代码 #include<iostream& ...

  6. 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. 题解:很显然只有 \( ...

  7. (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 ...

  8. 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 ...

  9. 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 ...

  10. 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 ...

随机推荐

  1. 用友U8与MES系统API接口对接案例分析

    企业数字化转型:轻易云数据集成平台助力 U8 ERP+MES 系统集成 为什么选择数字化转型? 领导层对企业资源规划(ERP)的深刻理解促使了数字化转型的启动. 采用精确的"N+5" ...

  2. FreeSWITCH在answer前主动发dtmf

    操作系统 :CentOS 7.6_x64 FreeSWITCH版本 :1.10.9 NAT环境的主动外呼场景下,会遇到线路侧回铃音数据无法接收的问题,需要FreeSWITCH主动发送RTP数据,发送D ...

  3. 如何将 performance_schema 中的 TIMER 字段转换为日期时间

    问题 最近有好几个朋友问,如何将 performance_schema.events_statements_xxx 中的 TIMER 字段(主要是TIMER_START和TIMER_END)转换为日期 ...

  4. C# 从代码入门 Mysql 数据库事务

    目录 生成数据库数据 Mysql 数据库事务基础 数据库的并发一致性问题 数据库事务的隔离级别 BeginTransaction() 和 TransactionScope 的区别 BeginTrans ...

  5. 后端程序员必会的前端知识-01:html、css

    第一章. HTML 与 CSS HTML 是什么:即 HyperText Markup language 超文本标记语言,咱们熟知的网页就是用它编写的,HTML 的作用是定义网页的内容和结构. Hyp ...

  6. python生成列表的时间复杂度

    在刷题的时候,经常碰到需要生成非常大的邻接矩阵,往往我们都是用 list 存储,但是我在最近刷题的过程中就遇上了TLE的情况,原因就是生成邻接矩阵时间太花时间了. 先说结论:[ ]* n 比 [ fo ...

  7. 微信现金红包开发 PHP

    第一次在cnblogs发文章 微信商家后台-现金红包开发 sdk <?php class wxPay { //配置参数信息 const SHANGHUHAO = "1430998xxx ...

  8. Guava Cache 异步刷新技巧,你值得拥有!

    Guava Cache是一款非常优秀的本地缓存框架,提供简洁易用的 API 供开发者使用. 这篇文章,我们聊聊如何使用 Guava Cache 异步刷新技巧带飞系统性能 . 1 基本用法 首先,在 J ...

  9. Spring 中循环依赖的处理

    Spring 提供了十分强大的依赖注入功能,使得我们不再需要手动去管理对象的依赖项.然而,在实际的使用场景中,可能会遇到类似下面的依赖异常: Exception encountered during ...

  10. 斯坦福课程 UE4 C++ ActionRoguelike游戏实例教程 01.基础AI与行为树

    斯坦福课程 UE4 C++ ActionRoguelike游戏实例教程 0.绪论 前言&摘要 本篇文章是基于斯坦福UE4 C++课程的学习记录.因为B站用户surkea由于学业原因,暂停了课程 ...