Codeforces Round #700 (Div. 2) A ~ D1个人题解
Codeforces Round #700 (Div. 2)
比赛链接: Click Here
1480A. Yet Another String Game
因为Alice是要追求小,Bob追求大值,所以只要变为 a 或 z.
AC代码
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
for (cin >> _; _--;) {
string s;
cin >> s;
for (int i = 0; i < s.size(); ++i)
if (i % 2 == 0) {
if (s[i] == 'a') cout << 'b';
else cout << 'a';
} else {
if (s[i] != 'z') cout << 'z';
else cout << 'y';
}
cout << "\n";
}
return 0;
}
1480B. The Great Hero
排序,对英雄伤害少的排前面,统计总共打败的敌人数即可
AC代码
using ll = long long;
int _;
struct node {
ll a, b;
};
ll A, B;
bool cmp(node a, node b) {
ll d1 = (a.b / A + a.b % A != 0) * a.a, d2 = (b.b / A + b.b % A != 0) * b.a;
return d1 < d2;
}
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
for (cin >> _; _--;) {
int n, cnt = 0;
cin >> A >> B >> n;
vector<node> e(n);
for (int i = 0; i < n; ++i) cin >> e[i].a;
for (int i = 0; i < n; ++i) cin >> e[i].b;
sort(e.begin(), e.end(), cmp);
for (int i = 0; i < n; ++i) {
while (B >= 1 && e[i].b >= 1) e[i].b -= A, B -= e[i].a;
if (e[i].b <= 0) cnt++;
}
cout << (cnt == n ? "YES\n" : "NO\n");
}
return 0;
}
1480C. Searching Local Minimum
C题没做出来,待补。
1480D1. Painting the Array I
题意和思路来自网络

个人理解以后的AC代码
int _;
int a[210000];
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; ++i) cin >> a[i];
int lst = 0, sum = 0;
for (int i = 1; i <= n; ++i) {
if (a[i] == a[i + 1]) {
if (a[lst] != a[i])
sum += 2;
else {
bool f = false;
for (int j = i - 1; true; --j) {
if (a[j] != a[i] && a[j + 1] != a[i]) {
f = true;
break;
}
if (j == lst) break;
}
sum += f ? 2 : 1;
}
while (a[i] == a[i + 1]) ++i;
lst = i;
} else
sum++;
// cout << sum << "\n";
}
cout << sum << "\n";
return 0;
}
1480D2. Painting the Array II
D2昨天没啥想法就被弃掉了(老菜鸡了)
顺便贴一下朋友的D2代码
AC代码
int _;
int a[100005], b[100005], ans[100005], now[100005], pre[100005];
int dfs(int x) {
if (ans[x] != -1) return ans[x];
if (x == 0) return 0;
ans[x] = dfs(x - 1);
if (pre[x]) ans[x] = max(ans[x], dfs(pre[x] + 1) + 1);
return ans[x];
}
int main() {
int T = 1;
// cin>>T;
while (T--) {
int n, x = 0;
cin >> n;
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
for (int i = 1; i <= n; i++)
if (a[i] != a[i - 1]) b[++x] = a[i];
for (int i = 1; i <= x; i++) pre[i] = now[b[i]], now[b[i]] = i;
memset(ans, -1, sizeof(ans));
dfs(x);
int mx = 0;
for (int i = 1; i <= x; i++) mx = max(mx, ans[i]);
cout << x - mx << endl;
}
return 0;
}
Codeforces Round #700 (Div. 2) A ~ D1个人题解的更多相关文章
- Codeforces Round #609 (Div. 2)前五题题解
Codeforces Round #609 (Div. 2)前五题题解 补题补题…… C题写挂了好几个次,最后一题看了好久题解才懂……我太迟钝了…… 然后因为longlong调了半个小时…… A.Eq ...
- Codeforces Round #741 (Div. 2), problem: (D1) Two Hundred Twenty One (easy version), 1700
Problem - D1 - Codeforces 题意: 给n个符号(+或-), +代表+1, -代表-1, 求最少删去几个点, 使得 题解(仅此个人理解): 1. 这题打眼一看, 肯定和奇 ...
- Codeforces Round #700 (Div. 2) --- B(思维)
传送门 有必要提醒自己一下, 先把题读利索了(手动捂脸) 题目 B. The Great Hero The great hero guards the country where Homer li ...
- Codeforces Round #556 (Div. 2) D. Three Religions 题解 动态规划
题目链接:http://codeforces.com/contest/1150/problem/D 题目大意: 你有一个参考串 s 和三个装载字符串的容器 vec[0..2] ,然后还有 q 次操作, ...
- Codeforces Round #604 (Div. 2) E. Beautiful Mirrors 题解 组合数学
题目链接:https://codeforces.com/contest/1265/problem/E 题目大意: 有 \(n\) 个步骤,第 \(i\) 个步骤成功的概率是 \(P_i\) ,每一步只 ...
- Codeforces Round #624 (Div. 3) F. Moving Points 题解
第一次写博客 ,请多指教! 翻了翻前面的题解发现都是用树状数组来做,这里更新一个 线段树+离散化的做法: 其实这道题是没有必要用线段树的,树状数组就能够解决.但是个人感觉把线段树用熟了会比树状数组更有 ...
- Codeforces Round #677 (Div. 3) E、G题解
E. Two Round Dances #圆排列 题目链接 题意 \(n\)(保证偶数)个人,要表演一个节目,这个节目包含两种圆形舞蹈,而每种圆形舞蹈恰好需要\(n/2\)个人,每个人只能跳一种圆形舞 ...
- Codeforces Round#402(Div.1)掉分记+题解
哎,今天第一次打div1 感觉头脑很不清醒... 看到第一题就蒙了,想了好久,怎么乱dp,倒过来插之类的...突然发现不就是一道sb二分吗.....sb二分看了二十分钟........ 然后第二题看了 ...
- Codeforces Round #604 (Div. 2) 练习A,B题解
A题 链接 思路分析: 因为只需要做到相邻的不相同,利用三个不同的字母是肯定可以实现的, 所以直接先将所有的问号进行替换,比如比前一个大1,如果与后面的冲突,则再加一 代码(写的很烂): #inclu ...
- Codeforces Round #599 (Div. 2)的简单题题解
难题不会啊…… 我感觉写这个的原因就是因为……无聊要给大家翻译题面 A. Maximum Square 简单题意: 有$n$条长为$a_i$,宽为1的木板,现在你可以随便抽几个拼在一起,然后你要从这一 ...
随机推荐
- Access denied for user ‘root‘@‘localhost‘ (using password:YES)解决方法
修改jdbc.properties文件的密码
- 理解Mysql索引原理及特性
作为开发人员,碰到了执行时间较长的sql时,基本上大家都会说"加个索引吧".但是索引是什么东西,索引有哪些特性,下面和大家简单讨论一下. 1 索引如何工作,是如何加快查询速度 索引 ...
- erp——绩效考核系统——数据需求说明书
绩效考核--数据需求说明书 1.引言 1.1编写目的 数据要求说明书详细的提供了系统中各个数据的流向,是设计数据库的关键所在,为以后的编码以及测试提供一份可靠的依据. 1.2 对象 本<数据要求 ...
- Python 潮流周刊第 31 期(摘要)
本周刊由 Python猫 出品,精心筛选国内外的 250+ 信息源,为你挑选最值得分享的文章.教程.开源项目.软件工具.播客和视频.热门话题等内容.愿景:帮助所有读者精进 Python 技术,并增长职 ...
- @Async实现异步任务
1.@Async是SpringBoot自带的一个执行步任务注解 @EnableAsync // 开启异步 @SpringBootApplication public class Application ...
- ElasticSearch之cat templates API
命令样例如下: curl -X GET "https://localhost:9200/_cat/templates?v=true&pretty" --cacert $ES ...
- IDEA美化教程
一.IDEA 字体大小怎么设置(图文教程) IDEA 初次安装时,默认字体非常小,这种情况下,代码阅读起来非常费劲,对保护视力非常不友好.那么,要如何在 IDEA 中设置字体大小呢? 这里介绍两种方法 ...
- intel 虚拟化 VT-d VT-x VT-c 的区别
intel 虚拟化 VT-d VT-x VT-c 有什么区别,各是什么意思,有什么作用 简单描述理解 VT-d VT-x VT-c VT-d 英文全程为 Virtualization Technolo ...
- adobe全家桶破解网站
原文链接:https://baiyunju.cc/8602 总有一些国内.外的大神在破解Adobe全家桶软件,包括Windows.Mac系统最新版的2021.2022版PS.AI.PR.PL.ME.I ...
- 使用 PostgreSQL 实现 PageRank
PageRank 算法 作为 Google 最早的一个网页排名算法,该算法在早期的搜索引擎中是搜索结果最为准确的,同时也是 Google 发家的一个重要算法.尽管这些年来该算法不再是 Google ...