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的木板,现在你可以随便抽几个拼在一起,然后你要从这一 ...
随机推荐
- 0x04.信息收集
探针 被动:借助网上的一些接口查询或者网上已经获取到的,查看历史信息. 主动:使用工具,从本地流量出发,探测目标信息,会发送大量流量到对方服务器上. 谷歌语法 懒人语法:https://pentest ...
- Prometheus+Grafana 监控平台实践-搭建&常用服务监控&告警
前言 Prometheus 是一个开放性的监控解决方案,通过各种 Exporter 采集当前主机/服务的数据,和 Grafana 相结合可以实现强大的监控和可视化功能 本篇将分享使用 docker c ...
- 带圆角的虚线边框?CSS 不在话下
今天,我们来看这么一个非常常见的切图场景,我们需要一个带圆角的虚线边框,像是这样: 这个我们使用 CSS 还是可以轻松解决的,代码也很简单,核心代码: div { border-radius: 25p ...
- Educational Codeforces Round 26 Problem C
C. Two Seals time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- 火山引擎ByteHouse基于云原生架构的实时导入探索与实践
更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 随着企业降本增效.智能化数据决策需求的增强,传统的商业数据库已经难以满足和响应快速增长的业务诉求.在此背景下,云原 ...
- 复现YOLO5所遇到的问题
一. 解决方案: 由于没有影响模型继续运行,理解为简单的warning.根据查询问题,推断是由于 pytorch和torchvision的版本原因导致的. 二. 解决方案: 由于没有影响模型继续运行, ...
- Odoo16—国际化翻译
开发odoo系统模块的时候,如果一开始就有国际化的需求,无论是模型的定义还是视图的构建,建议使用英语作为第一语言:一方面,英语本身就是一种国际化的语言:另一方面,odoo内置模型字段描述如Create ...
- IOS关闭锁屏状态下左滑相机
IOS 锁屏状态下,左滑就会打开相机,还不能关闭.这种功能说真的,没有啥用,还很麻烦.看了一圈教程,写的也是没写全.自己再写一个,以后换手机还用得上. 注:此方法会导致微信的扫一扫不可用 1.找到&q ...
- Ubuntu基线指导手册
Ubuntu基线指导手册 1. 身份鉴别策略组检测 准备: 安装一个PAM模块来启用cracklib支持,这可以提供额外的密码检查功能. 在Debian,Ubuntu或者Linux Mint使用命 ...
- Element UI的第一个程序(标签使用)
1:Element UI 官方文档:https://element.faas.ele.me/ 2:Element UI是什么? 网站快速成型工具 Element,一套为开发者.设计师和产品经理准备的基 ...