Codeforces Round #710 (Div. 3)个人简单题解
补题链接:Here
Proble-A. Strange Table
根据 x 确定坐标确定的行数和列数。
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int _;
for (cin >> _; _--;) {
ll n, m, x;
cin >> n >> m >> x;
x--;
ll col = x / n, row = x % n;
cout << row * m + col + 1 << "\n";
}
return 0;
}
Problem-B. Partial Replacement
题意:n组样例,每组单走一个字符串s,s由‘*’和‘.’组成,可以把'*'号变成‘X'号,但是需要满足,首尾的‘.’号要变成‘X’号,相邻'X'距离不能超过k。求最终X个数最小值。
长度很小,直接暴搜,找到*号之后,下一个位置从x+k开始倒着找,找到最后直接返回,这样肯定是最小的了。
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int _;
for (cin >> _; _--;) {
int n, k;
string s;
cin >> n >> k >> s;
int cnt = 1;
int i = s.find_first_of('*');
while (true) {
int j = min(n - 1, i + k);
for (; i < j and s[j] == '.'; --j)
;
if (i == j) break;
i = j, cnt++;
}
cout << cnt << "\n";
}
return 0;
}
Problem-C. Double-ended Strings
两个字符串不大,可暴力
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int _;
for (cin >> _; _--;) {
string a, b;
cin >> a >> b;
int cnt = 0;
int n = a.size(), m = b.size();
for (int len = 1; len <= min(n, m); ++len) {
for (int i = 0; i + len <= n; ++i)
for (int j = 0; j + len <= m; ++j)
if (a.substr(i, len) == b.substr(j, len))
cnt = max(cnt, len);
}
cout << n + m - 2 * cnt << '\n';
}
return 0;
}
Problem-D. Epic Transformation
这里要用一下优先队列去模拟消除的过程。
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int _;
for (cin >> _; _--;) {
int n, x;
cin >> n;
map<int, int> mp;
priority_queue<pair<int, int>> q;
for (int i = 0; i < n; ++i) {
cin >> x;
mp[x]++;
}
for (auto [x, y] : mp) q.push({y, x});
int Size = n;
while (q.size() >= 2) {
auto [cnt1, x1] = q.top();
q.pop();
auto [cnt2, x2] = q.top();
q.pop();
cnt1--, cnt2--, Size -= 2;
if (cnt1) q.push({cnt1, x1});
if (cnt2) q.push({cnt2, x2});
}
cout << Size << "\n";
}
return 0;
}
Problem-E. Restoring the Permutation
E题待补...
Codeforces Round #710 (Div. 3)个人简单题解的更多相关文章
- Codeforces Round #612 (Div. 2) 前四题题解
这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...
- Codeforces Round #198 (Div. 2)A,B题解
Codeforces Round #198 (Div. 2) 昨天看到奋斗群的群赛,好奇的去做了一下, 大概花了3个小时Ak,我大概可以退役了吧 那下面来稍微总结一下 A. The Wall Iahu ...
- Codeforces Round #672 (Div. 2) A - C1题解
[Codeforces Round #672 (Div. 2) A - C1 ] 题目链接# A. Cubes Sorting 思路: " If Wheatley needs more th ...
- Codeforces Round #599 (Div. 2)的简单题题解
难题不会啊…… 我感觉写这个的原因就是因为……无聊要给大家翻译题面 A. Maximum Square 简单题意: 有$n$条长为$a_i$,宽为1的木板,现在你可以随便抽几个拼在一起,然后你要从这一 ...
- Codeforces Round #614 (Div. 2) A-E简要题解
链接:https://codeforces.com/contest/1293 A. ConneR and the A.R.C. Markland-N 题意:略 思路:上下枚举1000次扫一遍,比较一下 ...
- Codeforces Round #610 (Div. 2) A-E简要题解
contest链接: https://codeforces.com/contest/1282 A. Temporarily unavailable 题意: 给一个区间L,R通有网络,有个点x,在x+r ...
- Codeforces Round #310 (Div. 2)--A(简单题)
http://codeforces.com/problemset/problem/556/A 题意:给一个01字符串,把所有相邻的0和1去掉,问还剩下几个0和1. 题解:统计所有的0有多少个,1有多少 ...
- Codeforces Round #198 (Div. 2)C,D题解
接着是C,D的题解 C. Tourist Problem Iahub is a big fan of tourists. He wants to become a tourist himself, s ...
- Codeforces Round #619 (Div. 2) A~D题解
最近网课也开始了,牛客上一堆比赛题目也没补,所以就D题后面的也懒得补了 A.Three String 水题 #include <cstdio> #include <cstring&g ...
- Codeforces Round #611 (Div. 3) A-F简要题解
contest链接:https://codeforces.com/contest/1283 A. Minutes Before the New Year 题意:给一个当前时间,输出离第二天差多少分钟 ...
随机推荐
- 练习感受以及经验总结(ing)
connection = DriverManager.getConnection(url, user,password );顺序一定不能搞错,当时顺序写错了.查bug查了一晚上.得益于两个函数都用到了 ...
- 基于DotNetty实现自动发布 - 自动检测代码变化
前言 很抱歉没有实现上一篇的目标:一键发布,因为工作量超出了预期,本次只实现了 Git 代码变化检测 已完成的功能 解决方案的项目发现与配置 首次发布需要手动处理 自动检测代码变化并解析出待发布的文件 ...
- [ABC246G] Game on Tree 3
Problem Statement There is a rooted tree with $N$ vertices, Vertex $1$ being the root. For each $i = ...
- skywalking自定义插件开发
skywalking是使用字节码操作技术和AOP概念拦截Java类方法的方式来追踪链路的,由于skywalking已经打包了字节码操作技术和链路追踪的上下文传播,因此只需定义拦截点即可. 这里以sky ...
- 启发式搜索(heuristic search)———A*算法
在宽度优先和深度优先搜索里面,我们都是根据搜索的顺序依次进行搜索,可以称为盲目搜索,搜索效率非常低. 而启发式搜索则大大提高了搜索效率,由这两张图可以看出它们的差别: (左图类似与盲搜,右图为启发式搜 ...
- Blazor入门100天 : 自做一个支持长按事件的按钮组件
好长时间没继续写这个系列博客了, 不知道大家还记得我吗? 话不多说,直接开撸. 1. 新建 net8 blazor 工程 b19LongPressButton 至于用什么模式大家各取所需, 我创建的是 ...
- ElasticSearch-Mapping类型映射-增删改查
https://www.elastic.co/guide/en/elasticsearch/reference/6.8/mapping.html 7.x版本后默认都是_doc类型 增加Mapping映 ...
- 【2020】装了VirtualBox后VMware Workstation无法使用SSH连接Centos的解决方法
装了个VirtualBox,然后发现无法使用Xshell远程Vmware中的centos了,一开始感觉是虚拟网卡冲突了,发现把VirtualBox的虚拟网卡禁用就可以使用,但是好麻烦啊??每次我特么要 ...
- Scrapy-redis组件,实现分布式爬虫
安装包 pip install -U scrapy-redis settings.py ##### Scrapy-Redis ##### ### Scrapy指定Redis 配置 ### # 其他默认 ...
- 3D网站LOGO动画
相关技术和实现分析 3D模型 帧动画 threejs 推荐用blender创建3d模型,k帧实现从上到下翻转的帧动画 threejs 中执行帧动画,并关联滚动条 threejs 模型材质 Blende ...