07 2020 档案

摘要:比赛链接:https://pintia.cn/market/item/1287964475579875328 7-1 对称日 题解 模拟,注意年月日不足位在前面补零。 代码 #include <bits/stdc++.h> using namespace std; map<string, strin 阅读全文
posted @ 2020-07-28 20:30 Kanoon 阅读(465) 评论(0) 推荐(0)
摘要:题目链接:http://poj.org/problem?id=2456 题意 给出 $n$ 座牛舍的坐标 $x_i$,问 $m$ 头牛两两之间最小间距的最大值。 题解 二分最大值,然后把牛贪心地在牛舍间分配即可。 代码 #include <cstdio> #include <algorithm> u 阅读全文
posted @ 2020-07-27 23:50 Kanoon 阅读(217) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544 题意 给出一个 $n$ 点 $m$ 边的带权无向图,找出结点 $1$ 到结点 $n$ 的路径最小权。($n \le 100, m \le 10000$) 题解 $n$ 的范围较小,可以用 $O_{ 阅读全文
posted @ 2020-07-26 23:30 Kanoon 阅读(147) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1384/problem/A 题意 构造 $n+1$ 个字符串,使得 $n$ 对相邻字符串的相同前缀长度对应于数组 $a$ 。 题解 构造一个足够长的字符串,每次反转前缀不同处的字符即可。 代码 #include <bits/s 阅读全文
posted @ 2020-07-25 23:45 Kanoon 阅读(200) 评论(0) 推荐(0)
摘要:比赛链接:https://codeforces.com/contest/1390 A. 123-sequence 题意 给出一个只含有 $1,2,3$ 的数组,问使所有元素相同至少要替换多少元素。 题解 统计数组中出现次数最多的元素即可。 代码 #include <bits/stdc++.h> us 阅读全文
posted @ 2020-07-24 20:00 Kanoon 阅读(200) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1285 题意 有 $n$ 个比赛队($1 \le n \le 500$),编号依次为 $1,2,3,\dots,n$ 进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能 阅读全文
posted @ 2020-07-23 20:30 Kanoon 阅读(109) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1382/problem/D 题意 给出一个大小为 $2n$ 的排列,判断能否找到两个长为 $n$ 的子序列,使得二者归并排序后能够得到该排列。 题解 将原排列拆分为一个个连续子序列,每次从大于上一子序列首部的元素处分出下一连续 阅读全文
posted @ 2020-07-22 12:45 Kanoon 阅读(235) 评论(0) 推荐(0)
摘要:做完前四题还有一个半小时... 比赛链接:https://codeforces.com/contest/1382 A. Common Subsequence 题意 给出两个数组,找出二者最短的公共子序列。 题解 最短即长为一。 代码 #include <bits/stdc++.h> using na 阅读全文
posted @ 2020-07-22 00:35 Kanoon 阅读(299) 评论(0) 推荐(0)
摘要:题目链接:https://vjudge.net/problem/UVA-10305 相似题目:CF1385E(完 全 一 致) #include <bits/stdc++.h> using namespace std; int main() { int n, m; while (cin >> n > 阅读全文
posted @ 2020-07-21 22:02 Kanoon 阅读(138) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1379/problem/C 题意 有 $m$ 种花,每种花数量无限,第一次购买一种花收益为 $a_i$,之后每一次购买收益为 $b_i$,问买 $n$ 朵花的最大收益为多少。 题解 感觉是个 $dp$,实际上是个贪心。 一定是 阅读全文
posted @ 2020-07-20 17:15 Kanoon 阅读(261) 评论(3) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1379/problem/B 题意 给出三个正整数 $l,r,m$,判断在区间 $[l,r]$ 内是否有 $a,b,c$ 满足存在正整数 $n$,使得 $n \cdot a + b - c = m$ 。 题解 最容易想的一种情况 阅读全文
posted @ 2020-07-20 16:45 Kanoon 阅读(255) 评论(0) 推荐(2)
摘要:题目链接:https://codeforces.com/contest/1379/problem/A 题意 给出一个由 '?' 和小写字母组成的字符串,可以将 '?' 替换为小写字母,判断是否存在一种替换方案使得字符串只包含一个 'abacaba' 子串。 题解 首先计算原字符串中所求子串的个数: 阅读全文
posted @ 2020-07-20 16:11 Kanoon 阅读(224) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1385/problem/E 题意 $n$ 个结点之间有 $m$ 条边,其中有无向边和有向边,判断能否通过指定无向边的方向构造出有向无环图。 题解 如果原图开始就有有向环则无解。否则,可以通过拓扑排序来避免形成环。 代码 #in 阅读全文
posted @ 2020-07-19 17:10 Kanoon 阅读(126) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1385/problem/D 题意 一个小写字母串称为 $c-good\ string$,如果至少满足以下条件之一: 字符串长度为 $1$,包含字母 $c$ 字符串前一半都为字母 $c$,后一半为 $(c+1)-good\ st 阅读全文
posted @ 2020-07-18 01:06 Kanoon 阅读(194) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1385/problem/C 题意 去除一个数组的最短前缀使得余下的数组每次从首或尾部取元素可以排为非减序。 题解一 当两个大数夹着一个小数那么第一个大数及其之前的数必须要去掉,比如 $1,1,2,1,2$,要去除的前缀长为 $ 阅读全文
posted @ 2020-07-18 01:04 Kanoon 阅读(258) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1385/problem/B 题意 有两个大小为 $n$ 的相同的排列,每次从二者或二者之一的首部取元素排入新的数组,给出这个大小为 $2n$ 的数组,找到原先的排列。 题解 忽略所有第二次出现的数即可。 代码 #include 阅读全文
posted @ 2020-07-18 01:02 Kanoon 阅读(212) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1385/problem/A 题意 给出三个正整数 $x,y,z$,找出三个正整数 $a,b,c$ 使得 $x = max(a, b), y = max(a, c), z = max(b, c)$ 。 题解 假设有 $a \le 阅读全文
posted @ 2020-07-18 01:00 Kanoon 阅读(236) 评论(0) 推荐(0)
摘要:题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805526272000000 题意 给出两个多项式,输出二者相加后非零项的总个数及其次方、系数。 代码 #include <bits/stdc++.h> using 阅读全文
posted @ 2020-07-17 21:50 Kanoon 阅读(103) 评论(0) 推荐(0)
摘要:题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805528788582400 题意 给出两个数,将二者的和从个位起以三位为间隔输出。 代码 #include <bits/stdc++.h> using names 阅读全文
posted @ 2020-07-17 21:46 Kanoon 阅读(125) 评论(0) 推荐(0)
摘要:代码摘自Github上Google开源的C++单元测试工具。 项目地址:https://github.com/google/googletest // Returns true if and only if n is a prime number. bool IsPrime(int n) { // 阅读全文
posted @ 2020-07-16 23:00 Kanoon 阅读(251) 评论(0) 推荐(0)
摘要:比赛链接:https://pintia.cn/market/item/1097414703086837760 A - 检查密码 Tips 密码中可能有空格,所以需要用 getline() 。 代码 #include <bits/stdc++.h> using namespace std; void 阅读全文
posted @ 2020-07-15 13:00 Kanoon 阅读(274) 评论(0) 推荐(1)
摘要:比赛链接:https://pintia.cn/market/item/1103202531901689856 7-1 大美数 题解 模拟即可。 Tips 这题通过率只有 $0.09$,可能是大部分人搞错了整除的关系,$a$ 整除 $b$ 表示为 $b\ \%\ a = 0$ 。 代码 #includ 阅读全文
posted @ 2020-07-14 13:00 Kanoon 阅读(268) 评论(2) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1380/problem/D 题意 给出一个大小为 $n$ 的排列 $a$ 和一个序列 $b$,有两种操作: 花费 $x$ 消除连续 $k$ 个数 花费 $y$ 选取两个相邻的数,消除较小的数 问能否将 $a$ 变为 $b$,以 阅读全文
posted @ 2020-07-13 23:59 Kanoon 阅读(356) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1380/problem/C 题意 给 $n$ 个数分组,要求每组的最小值乘以该组数的个数不小于 $x$ 。 题解 从大到小依次分即可。 代码 #include <bits/stdc++.h> using ll = long l 阅读全文
posted @ 2020-07-13 23:36 Kanoon 阅读(287) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1380/problem/B 题意 你在和一个机器人玩石头剪刀布,给出一个长为 $n$ 的出拳序列,机器人会从某一处开始出拳 $n$ 次,问你要怎么出拳才能赢尽可能多的回合。 题解 全部反制机器人会出的最多的拳即可。 代码 #i 阅读全文
posted @ 2020-07-13 23:34 Kanoon 阅读(317) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1380/problem/A 题意 给出一个大小为 $n$ 的排列,找出是否有三个元素满足 $p_i < p_j\ and\ p_j > p_k$ 。 题解 如果排列为增序或降序则无解,否则一定存在三个相邻的元素满足 $p_i 阅读全文
posted @ 2020-07-13 23:30 Kanoon 阅读(343) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1372/problem/D 题意 给出奇数个数围成的环,每次可以将一个数替换为相邻两个数的和并删除相邻的两个数,问最后余下的数的最大值。 题解 即从 $n$ 个数中选取 $\frac{n+1}{2}$ 个数,且这些数中最多有一 阅读全文
posted @ 2020-07-12 21:18 Kanoon 阅读(235) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1372/problem/C 题意 给出一个大小为 $n$ 的排列,每次操作可以选取一个连续子数组任意排列其中的元素,要求每个元素的位置必须与操作前不同,问将排列排为升序至少需要操作多少次。 题解 最多需要操作 $2$ 次,之后 阅读全文
posted @ 2020-07-12 21:09 Kanoon 阅读(281) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1372/problem/B 题意 给出一个正整数 $n$,找到两个正整数 $a,b$ 满足 $a+b = n$ 且 $LCM(a,b)$ 最小。 题解 $a$ 或 $b$ 中一定有 $n$ 的因子,枚举即可。 证明 若 $a, 阅读全文
posted @ 2020-07-12 20:58 Kanoon 阅读(253) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1372/problem/A 题意 构造一个大小为 $n$ 的数组 $a$,要求满足 $1 \le a_i \le n$,且不存在 $a_x + a_y \neq a_z$ 。 题解 最好想的就是全部构造成相等的元素。 代码 # 阅读全文
posted @ 2020-07-12 20:49 Kanoon 阅读(192) 评论(0) 推荐(0)
摘要:比赛链接:https://pintia.cn/market/item/1203557339918098432 7-1 2019数列 题解 简单的递推。 代码 #include <bits/stdc++.h> using namespace std; int main() { int f[1005] 阅读全文
posted @ 2020-07-11 12:10 Kanoon 阅读(243) 评论(0) 推荐(0)
摘要:比赛链接:https://pintia.cn/market/item/1170913498742468608 7-1 B是A的多少倍 题意 将一个数后 $d$ 位截下移到最高位前面,得到的新数是原数的多少倍。 代码 #include <bits/stdc++.h> using namespace s 阅读全文
posted @ 2020-07-10 16:45 Kanoon 阅读(204) 评论(0) 推荐(0)
摘要:题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/994805320306507776 #include <bits/stdc++.h> using namespace std; int main() { int n; c 阅读全文
posted @ 2020-07-09 23:20 Kanoon 阅读(192) 评论(0) 推荐(0)
摘要:题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/994805324509200384 #include <bits/stdc++.h> using namespace std; map<char, string> mp{ 阅读全文
posted @ 2020-07-08 22:30 Kanoon 阅读(112) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1375/problem/E 题意 给出一个大小为 $n$ 的数组 $a$,对数组中的所有逆序对进行排序,要求按照排序后的顺序交换每一对逆序对后数组为非递减数组。 题解 先将顺组的下标按元素大小排为非递减序,此即交换完所有的逆序 阅读全文
posted @ 2020-07-07 23:25 Kanoon 阅读(171) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1375/problem/D 题意 给出一个大小为 $n$,元素值位于 $[0,n]$ 之间的数组,每次可以将一个元素替换为数组中未出现过的最小非负整数,最多替换 $2n$ 次,输出一种使得数组为非递减数组的替换方案。 题解 将 阅读全文
posted @ 2020-07-06 23:03 Kanoon 阅读(217) 评论(0) 推荐(1)
摘要:题目链接:https://codeforces.com/contest/1375/problem/C 题意 给出一个大小为 $n$ 的排列 $a$,如果 $a_i < a_{i+1}$,则可以选择移去二者之一,判断排列最终能否只剩一个数。 题解一 考虑小于 $a_0$ 的所有的数,如果这些数都可以移 阅读全文
posted @ 2020-07-06 22:53 Kanoon 阅读(213) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1375/problem/B 题意 给出一个 $n \times m$ 的方阵,每个方格中有一个非负整数,一个好方格定义如下: 方格中的数字等于四周数字大于 $0$ 的方格总数 可以增加任意方格中的数字任意次,判断能否将初始方阵 阅读全文
posted @ 2020-07-06 22:40 Kanoon 阅读(317) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1375/problem/A 题意 给出一个大小为 $n$ 的数组 $a$,可以反转每个数的正负,要求: 至少有 $\frac{n - 1}{2}$ 对相邻的数满足 $a_{i+1} - a_i \ge 0$ 至少有 $\fra 阅读全文
posted @ 2020-07-06 22:21 Kanoon 阅读(210) 评论(0) 推荐(0)
摘要:比赛链接:https://atcoder.jp/contests/abc173/tasks A - Payment 题意 计算只用 $1000$ 元支付某个价格 $n$ 的找零是多少。 代码 #include <bits/stdc++.h> using namespace std; int main 阅读全文
posted @ 2020-07-05 22:30 Kanoon 阅读(367) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2072 题意 每行输入由小写字母和空格组成,统计每行中不同的单词数。 题解 题解一 比较简洁的解法,读入每行输入后重定向至字符流 $stringstream$,与 uva10815 相似。 代码 #inc 阅读全文
posted @ 2020-07-04 18:40 Kanoon 阅读(188) 评论(0) 推荐(0)
摘要:比赛链接:https://codeforces.com/contest/1270 A. Card Game 题意 有两个人在玩卡牌游戏,规则如下: 共有 $n$ 张牌,值为 $1$ 到 $n$ 两个人各出一张牌,牌大者拿走两张牌 手中先无牌者输掉游戏 给出一开始两个人的手牌情况(至少都有一张牌),判 阅读全文
posted @ 2020-07-03 23:55 Kanoon 阅读(151) 评论(0) 推荐(0)
摘要:比赛链接:https://codeforces.com/contest/1371 A. Magical Sticks 题意 有 $n$ 根小棍,长度从 $1$ 到 $n$,每次可以将两根小棍连接起来,问最多有多少根小棍长度相同。 题解 如:1 2 3 4 5,相同长度最多的情况为 1+4 2+3 5 阅读全文
posted @ 2020-07-02 23:55 Kanoon 阅读(226) 评论(0) 推荐(0)
摘要:比赛链接:https://atcoder.jp/contests/abc152/tasks A - AC or WA 题意 有 $n$ 个测试样例,通过了 $m$ 个,判断是否 AC 。 代码 #include <bits/stdc++.h> using namespace std; int mai 阅读全文
posted @ 2020-07-01 18:20 Kanoon 阅读(372) 评论(0) 推荐(0)