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 题意:给一个当前时间,输出离第二天差多少分钟 ...
随机推荐
- Ubuntu 18.04替换默认软件源
安装Ubuntu 18.04后,默认源在国外,可以替换为国内的源以提升访问速度 参考https://mirrors.ustc.edu.cn/repogen/ sudo vi /etc/apt/sour ...
- 【Android】如何去掉默认标题栏
1.在AndroidManifest.xml文件中修改并添加以下代码 android:theme="@style/Theme.AppCompat.NoActionBar" 2.在你 ...
- xv6:labs2 syscall
lab2 1.lab2的内容总结:关于系统调用整个跟踪过程: 使用系统调用时,用户态会通过软中断(trap,陷阱)进入内核中,由trap识别中断来自系统调用,然后调用syscall函数, 跟踪过程: ...
- RocketMQ一直打印RocketmqRemoting closeChannel: close the connection to remote address[] result: true
交代一下背景: RocketMQ服务端搭建在ECS上面(问题就出在这里) SpringBoot应用根据官网Demo(参考:https://github.com/apache/rocketmq-spri ...
- 精致的Javascript代码
1. 统计一个数组中,每个值的个数 var cards = [1, 2, 3, 4, 3, 2, 1, 4, 5] var dict = {}; for(var i = 0; i < cards ...
- Tampermonkey 编写一个首页跳转的脚本
每次打开浏览器时,总是会跳到一个其他的网页上,关也关不掉,很烦,写一个脚本直接跳转 // ==UserScript== // @name 页面跳转 // @version 1.0.1 // @auth ...
- SpringBoot事件机制
1.是什么? SpringBoot事件机制是指SpringBoot中的开发人员可以通过编写自定义事件来对应用程序进行事件处理.我们可以创建自己的事件类,并在应用程序中注册这些事件,当事件被触发时,可以 ...
- KNN算法实战——海伦约会(KDtree优化)
本文通过海伦约会的例子来测试之前写的KDTree的效果,并且探讨了特征是否进行归一化对整个模型的表现的影响.最后发现在机器学习中,特征归一化确实对模型能提供非常大的帮助. 1 from KDTree ...
- 如何对U盘的使用权限进行管控
对U盘的使用权限进行管控是保护企业信息安全的一项重要措施.以下是一些常见的方法,可帮助您有效管理和控制U盘的使用权限: 禁用U盘端口: 在公司计算机上禁用或限制USB端口的使用,特别是那些不需要使用U ...
- CF1340F Nastya and CBS 题解
题目大意 给定一个长度为 \(n(n \le 10 ^ 5)\) 的括号序列.要求支持两个操作: 修改某个位置的括号. 询问 \([l, r]\) 区间内的括号序列是否合法. 题目分析 显然,这道题是 ...