04 2020 档案

摘要:比赛链接:https://codeforces.com/contest/1278 A - Shuffle Hashing 题意 给你两个由小写字母组成的字符串 p 和 h,问 h 中是否有连续子串可以由 p 打乱后生成。(1≤|p|, |h|≤100) 题解一 给字符串 p 和在 h 中的 p 长连 阅读全文
posted @ 2020-04-30 23:53 Kanoon 阅读(121) 评论(0) 推荐(0)
摘要:比赛链接:https://codeforces.com/contest/1283 A - Minutes Before the New Year 题意 计算当前时间距离 $24:00$ 还有多少分钟。 Tips 小时要从 $23$ 减起。 代码 #include <bits/stdc++.h> us 阅读全文
posted @ 2020-04-29 17:40 Kanoon 阅读(144) 评论(0) 推荐(0)
摘要:比赛链接:https://codeforces.com/contest/1287 A - Angry Students 题意 有一字符串由 'A','P' 组成,每分钟 'A' 可以使右边相邻的 'P' 变为 'A',问字符串稳定下来需要多少分钟。 题解 查找每个 'A' 后的最长连续 'P' 串。 阅读全文
posted @ 2020-04-28 21:00 Kanoon 阅读(127) 评论(0) 推荐(0)
摘要:比赛链接:https://codeforces.com/contest/1342 A - Road To Zero 题意 有两个非负整数 x, y 以及两种操作: 支付 a 点代价使其中一个数加一或减一 支付 b 点代价使两个数都加一或减一 问使二者为 0 的最小代价。 思路 把较大的数减至与较小数 阅读全文
posted @ 2020-04-27 23:45 Kanoon 阅读(179) 评论(2) 推荐(0)
摘要:比赛链接:https://atcoder.jp/contests/abc164 A - Sheep and Wolves #include <bits/stdc++.h> using namespace std; int main() { int s, w; cin >> s >> w; cout 阅读全文
posted @ 2020-04-26 22:08 Kanoon 阅读(302) 评论(1) 推荐(2)
摘要:题目链接:https://vjudge.net/problem/UVA-1395 题意 给出一个 n (n ≤ 100)结点带权图,求生成树的边权中最小的极值差。 思路 将边按权值从小到大排序,枚举边集区间的左端点。 代码 #include <bits/stdc++.h> using namespa 阅读全文
posted @ 2020-04-25 23:47 Kanoon 阅读(147) 评论(0) 推荐(1)
摘要:比赛链接:https://codeforces.com/contest/1341 A - Nastya and Rice 题意 有 n 堆米,每堆质量在 [a-b,a+b] 之间,这些米的总质量是否可能在 [c-d,c+d] 之间。 思路 n 堆米的最小总质量为 n*(a-b),最大总质量为 n*( 阅读全文
posted @ 2020-04-24 21:18 Kanoon 阅读(308) 评论(0) 推荐(1)
摘要:题目链接:https://vjudge.net/problem/UVA-156 题意 所有单词可以重排其中的字母,找出一串文本中不能重排为其他单词的单词。 思路 将所有单词标准化并记录出现次数,输出只出现一次的原单词。 代码 #include <bits/stdc++.h> using namesp 阅读全文
posted @ 2020-04-23 21:50 Kanoon 阅读(109) 评论(0) 推荐(0)
摘要:题目链接:https://vjudge.net/problem/UVA-10815 题意 找出一段文本中的所有单词,以小写形式按照字典序输出。 思路 用空白符替换文本中所有非字母字符后再次读入。 代码 #include <bits/stdc++.h> using namespace std; set 阅读全文
posted @ 2020-04-23 21:47 Kanoon 阅读(144) 评论(0) 推荐(0)
摘要:题目链接:https://vjudge.net/problem/UVA-101 题意 有 0 ~ n - 1 个木块,一共有四种指令: move a onto b:把 a 和 b 上方的木块全部复位,然后把 a 放在 b 上面。 move a over b:把 a 上方的木块全部复位,然后把 a 放 阅读全文
posted @ 2020-04-22 20:37 Kanoon 阅读(159) 评论(0) 推荐(0)
摘要:题目链接:https://vjudge.net/problem/UVA-10474 题意 将 n 个数从小到大排序,输出 q 次询问中每个数第一次出现的下标 (1-indexed) 。 思路 排序,映射。 代码 #include <bits/stdc++.h> using namespace std 阅读全文
posted @ 2020-04-22 17:54 Kanoon 阅读(137) 评论(0) 推荐(0)
摘要:题目链接:https://vjudge.net/problem/UVA-136 第一次知道不加换行符也能wa... 题意 丑数是素因子只有 2、3、5 的数,输出第 1500 个丑数。 思路 按照定义从 1 开始构造即可。 代码 #include <bits/stdc++.h> using LL = 阅读全文
posted @ 2020-04-22 17:19 Kanoon 阅读(111) 评论(0) 推荐(0)
摘要:比赛链接:https://codeforces.com/contest/1343 A - Candies 题意 有一数列 x + 2x + 4x + ... + 2k-1x = n,输出 k ≥ 2 时任一满足该等式的一个 x 值。 思路 等比数列求和得 (2k-1) x = n,枚举 k 即可。 阅读全文
posted @ 2020-04-22 01:01 Kanoon 阅读(319) 评论(0) 推荐(2)
摘要:题目链接:http://poj.org/problem?id=3320 题意 在 n 个元素的数组中寻找包含所有大小元素的最短连续区间。 思路 双指针,在保证指针区间包括所有大小的同时每次删减最左端的一个大小。 代码 #include <cstdio> #include <set> #include 阅读全文
posted @ 2020-04-21 22:17 Kanoon 阅读(136) 评论(0) 推荐(0)
摘要:题目链接:http://poj.org/problem?id=3061 题意 在 n 个元素的数组中寻找和不小于 s 的最短连续区间。 思路 思路一 作前缀和二分查找,时间复杂度 $O_{(nlogn)}$ 。 代码一 #include <cstdio> #include <algorithm> u 阅读全文
posted @ 2020-04-21 21:14 Kanoon 阅读(204) 评论(0) 推荐(0)
摘要:比赛链接:https://codeforces.com/contest/1279 A - New Year Garland 题意 给出三种颜色花环的数量,要求相同颜色不相邻,问能否用完所有花环。 思路 考虑无解的情况,即较少的两种花环个数 + 1 < 较多的花环个数(+ 1 是因为较多的可以放在首尾 阅读全文
posted @ 2020-04-20 23:11 Kanoon 阅读(138) 评论(0) 推荐(0)
摘要:比赛链接:https://atcoder.jp/contests/abc163/tasks A - Circle Pond 题意 由半径输出圆周长。 代码 #include <bits/stdc++.h> using namespace std; int main() { double r; cin 阅读全文
posted @ 2020-04-19 23:00 Kanoon 阅读(398) 评论(15) 推荐(3)
摘要:比赛链接:https://codeforces.com/contest/1295 A - Display The Number 题意 输出按照电子钟表的格式用 n 段能组成的最大值。(1≤n≤105) 思路 每两段组成 1 增加位长,如有余与数首的 1 组成 7。 代码 #include <bits 阅读全文
posted @ 2020-04-19 16:39 Kanoon 阅读(119) 评论(0) 推荐(0)
摘要:比赛链接:https://ac.nowcoder.com/acm/contest/5278 A - 组队比赛 题意 将四个数分为两个和,使二者相差尽量小。 思路 最小数加最大数减去次小数和次大数。 代码 #include <bits/stdc++.h> using namespace std; in 阅读全文
posted @ 2020-04-18 17:06 Kanoon 阅读(185) 评论(0) 推荐(0)
摘要:上古oj:http://poj.org/problem?id=1852 题意 长 $l$ cm 的水平杆上有 $n$ 只蚂蚁,每只蚂蚁的速度均为 $1$ cm/s。当蚂蚁到达杆的一端时,它立即从杆上掉下来。当两只蚂蚁相遇时,他们转身开始向相反的方向行走。已知每只蚂蚁初始时距离左端的距离,蚂蚁初始面朝 阅读全文
posted @ 2020-04-17 16:06 Kanoon 阅读(113) 评论(0) 推荐(0)
摘要:比赛链接:https://codeforces.com/contest/1337 A. Ichihime and Triangle 题意 已知 $a,b,c,d$ ,选取 $a≤x≤b≤y≤c≤z≤d$,使得长为 $x,y,z$ 的三边能构成三角形。 思路 $x≤y≤z$,所以若想 $x+y>z$, 阅读全文
posted @ 2020-04-16 12:44 Kanoon 阅读(223) 评论(0) 推荐(0)
摘要:#include <bits/stdc++.h> using namespace std; int main() { string str; getline(cin, str); int cnt[26] = {}; for (char c : str) if (isalpha(c)) ++cnt[t 阅读全文
posted @ 2020-04-15 22:26 Kanoon 阅读(110) 评论(0) 推荐(0)
摘要:比赛链接:https://codeforces.com/contest/1335 A. Candies and Two Sisters 题意 把一个数拆成两个不等的数有多少种情况。 思路 奇数时除以二即可,偶数时需要再减去相等的情况。 代码 #include <bits/stdc++.h> usin 阅读全文
posted @ 2020-04-14 01:40 Kanoon 阅读(301) 评论(0) 推荐(0)
摘要:比赛链接:https://atcoder.jp/contests/abc162/tasks A - Lucky 7 #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << (to_stri 阅读全文
posted @ 2020-04-13 00:29 Kanoon 阅读(453) 评论(4) 推荐(3)
摘要:题目链接:https://codeforces.com/contest/1315/problem/A #include <bits/stdc++.h> using namespace std; void solve() { int a, b, x, y; cin >> a >> b >> x >> 阅读全文
posted @ 2020-04-12 14:32 Kanoon 阅读(99) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1315/problem/B #include <bits/stdc++.h> using namespace std; void solve() { int a, b, p; cin >> a >> b >> p; strin 阅读全文
posted @ 2020-04-12 14:27 Kanoon 阅读(137) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1315/problem/C #include <bits/stdc++.h> using namespace std; const int M = 220; int n, a[M], num[M]; void solve() 阅读全文
posted @ 2020-04-12 13:12 Kanoon 阅读(119) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1315/problem/D #include <bits/stdc++.h> using ll = long long; using namespace std; priority_queue<int> q; //默认是大顶堆 阅读全文
posted @ 2020-04-12 12:51 Kanoon 阅读(161) 评论(0) 推荐(0)
摘要:题目链接:https://www.luogu.com.cn/problem/P1090 #include <bits/stdc++.h> using namespace std; priority_queue<int, vector<int>, greater<int>> q; //小顶堆 int 阅读全文
posted @ 2020-04-12 12:49 Kanoon 阅读(119) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1334 A. Level Statistics 题意 一个关卡有玩家的尝试次数和通关次数,按时间顺序给出一个玩家 $n$ 个时刻的数据,判断这些数据是否合理。 思路 通关次数不会多于尝试次数:$c_i≤p_i$ 后一时刻的尝试 阅读全文
posted @ 2020-04-11 02:00 Kanoon 阅读(294) 评论(2) 推荐(0)
摘要:P1002 过河卒(dp) P1004 方格取数(多维dp) P1090 合并果子(优先队列) 阅读全文
posted @ 2020-04-10 17:24 Kanoon 阅读(140) 评论(0) 推荐(0)
摘要:题目链接:L2-012 关于堆的判断 题意 将一系列给定数字顺序插入一个初始为空的小顶堆 H[] 。随后判断一系列相关命题是否为真。命题分下列几种: x is the root:x 是根结点; x and y are siblings:x 和 y 是兄弟结点; x is the parent of 阅读全文
posted @ 2020-04-10 16:54 Kanoon 阅读(257) 评论(0) 推荐(0)
摘要:题目链接:L2-014 列车调度 题意 如果一个排列最终可以按照降序输出,至少需要多少个队列来存储。 思路 如果当前数比之前的数都大,则需要新开一个队列,否则每次替换掉第一个大于它的数。 证明 我们担心的是如果将一个较小的数接在一个较大的数后面,之后更长的递减序列会无法接在较大的数后面,但如果我们想 阅读全文
posted @ 2020-04-10 15:00 Kanoon 阅读(185) 评论(0) 推荐(0)
摘要:A. Little Artem 题意 有一 $n{\times}m$ 网格,输出一种使得 与白色相邻的黑色格数 = 与黑色相邻的白色格数 $+ 1$ 的染色方案。 思路 一角染白。 代码 #include <bits/stdc++.h> using namespace std; void solve 阅读全文
posted @ 2020-04-09 16:22 Kanoon 阅读(155) 评论(0) 推荐(0)
摘要:题目链接:http://poj.org/problem?id=1064 题意 有 N 条绳子,它们的长度分别为 Li 。如果从它们中切割出 K 条长度相同的绳子的话,这 K 条绳子每条最长能有多长?答案保留到小数点后 2 位。 思路 二分确认每次是否至少能切割出 K 条绳子。 代码 #include 阅读全文
posted @ 2020-04-08 14:53 Kanoon 阅读(110) 评论(0) 推荐(0)
摘要:比赛链接:https://atcoder.jp/contests/abc159/tasks A - The Number of Even Pairs 题意 已知奇偶数的个数,求和为偶数的数对个数。 代码 #include <bits/stdc++.h> using namespace std; lo 阅读全文
posted @ 2020-04-07 21:05 Kanoon 阅读(144) 评论(0) 推荐(0)
摘要:比赛链接:https://atcoder.jp/contests/abc160/tasks AtCoder Beginner Contest 160 A - Coffee #include <bits/stdc++.h> using namespace std; int main() { strin 阅读全文
posted @ 2020-04-06 20:31 Kanoon 阅读(343) 评论(13) 推荐(1)
摘要:比赛链接:https://atcoder.jp/contests/abc161/tasks AtCoder Beginner Contest 161 第一次打AtCoder的比赛,因为是日本的网站终于不用倒时差了233。 A - ABC Swap 可以直接按照交换后的顺序输出。 #include < 阅读全文
posted @ 2020-04-05 15:00 Kanoon 阅读(307) 评论(0) 推荐(0)
摘要:Codeforces Round #631 (Div. 2) A. Dreamoon and Ranking Collection 题意: 已知过去 $n$ 场比赛的排名,还可以再参加 $x$ 场,问从 $1$ 起可能获得的最长连续名次序列。 思路: 记录已经获得的名次,从 $1$ 开始没有获得的名 阅读全文
posted @ 2020-04-04 15:00 Kanoon 阅读(526) 评论(5) 推荐(1)
摘要:题目链接:https://www.luogu.com.cn/problem/P1004 原来还可以这么dp... 题意: 给出一个方阵的行列长和部分方格中的数,问从左上角走到右下角所能取得的数之和的最大值(走两遍,每个方格中的数取后为0)。 思路: $dp[i][j][k][l]$,$(i,j)$为 阅读全文
posted @ 2020-04-03 19:26 Kanoon 阅读(164) 评论(0) 推荐(0)
摘要:题目链接:https://www.luogu.com.cn/problem/P1002 题意: 棋盘上,卒从(0,0)只能向右或下走,不能走马所在和马控制的点,问到某一点的方案数。 思路: 标记不可访问的九个点后逐行递推:$dp[i][j]=dp[i-1][j]+dp[i][j-1]$。 #incl 阅读全文
posted @ 2020-04-03 19:15 Kanoon 阅读(154) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/510/problem/D 题意: 给你一些数,问能否用它们组成所有自然数,如果可以输出最小代价(一个数的代价只需计入一次)。 思路: 裴蜀定理(又名贝祖定理):存在$x$,$y$,使得$ax+by=gcd(a,b)$。 所以只 阅读全文
posted @ 2020-04-02 23:45 Kanoon 阅读(316) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/510/problem/C 题意: 寻找一种字典序使一些字符串从小到大满足该字典序。 思路: 数据范围比较小,模拟一下拓扑排序即可。 #include <bits/stdc++.h> using namespace std; i 阅读全文
posted @ 2020-04-02 23:39 Kanoon 阅读(161) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/510/problem/B 题意: 找出矩阵中由一种字母组成的环(至少由四个点组成)。 思路: 给每个点设置一个搜索深度,如果同种字母的两个相邻点深度相差大于等于3,那么它们就可以组成一个环。 #include <bits/st 阅读全文
posted @ 2020-04-02 23:35 Kanoon 阅读(125) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/510/problem/A 题意: 用'.'和'#'输出蛇状图形。 思路: 需要找下规律的模拟题。 #include <bits/stdc++.h> using namespace std; const int M=60; in 阅读全文
posted @ 2020-04-02 23:31 Kanoon 阅读(129) 评论(0) 推荐(0)
摘要:题目链接:https://codeforces.com/contest/1332 A. Exercising Walk 可走的最远距离:左:x-x1,右:x2-x,下:y-y1,上:y2-y 如果可以移动,通过折返行走,两个相对方向至少有一个可以消为0,然后看余下步数是否小于等于该方向可走的最远距离 阅读全文
posted @ 2020-04-01 00:40 Kanoon 阅读(473) 评论(0) 推荐(0)