摘要: 7.1 ① 2019 USP-ICMC 链接:https://codeforces.com/gym/102302 ② Codeforces Round #654 (Div. 2) 链接: https://codeforces.com/contest/1371 题解: https://www.cnbl 阅读全文
posted @ 2020-07-02 23:26 overrate_wsj 阅读(240) 评论(0) 推荐(0) 编辑
摘要: A - Clam and Fish(贪心) 思路: 贪心,首先有鱼一定钓鱼,将没有鱼的天数单独拉出来考虑 首先从无鱼的第一天开始枚举,若当前天数有蛤蜊就收集,若啥都没,则用手头的蛤蜊换鱼 同时注意当当前手头的蛤蜊数等于剩余的天数,则剩余天数每天都可以换一条鱼 代码: #include<iostrea 阅读全文
posted @ 2020-07-20 00:54 overrate_wsj 阅读(239) 评论(0) 推荐(0) 编辑
摘要: A. All with Pairs(KMP+Hash+map) 思路: 我们很容易想到的一个方法就是,就算出每个字符串的每个后缀的哈希值将其存入一个$map$,然后计算每个前缀的哈希值,在$map$中查看有多少个后缀的哈希值与其相同,累加即为答案 但是这样做有时候我们会重复计数,比如在对$“aba” 阅读全文
posted @ 2020-07-16 11:12 overrate_wsj 阅读(225) 评论(0) 推荐(0) 编辑
摘要: A-B-Suffix Array(后缀数组+sort) 思路: 通过仔细分析与关系,我们可以发现以下的一些规律 对于任意后缀其B数组的第一个元素一定为$0$,并且B数组的开头一定为$01111......$(1的个取决于开头有多少个连续的相同字符) 例如$aaabba = 0111013,aaabb 阅读全文
posted @ 2020-07-14 13:21 overrate_wsj 阅读(258) 评论(0) 推荐(0) 编辑
摘要: A - Is It Easy ?(签到题) #include<iostream> #include<algorithm> using namespace std; int main() { int n,m; cin>>n>>m; cout<<n*m; } View Code B. Road to A 阅读全文
posted @ 2020-07-11 00:38 overrate_wsj 阅读(403) 评论(0) 推荐(0) 编辑
摘要: A - Mental Rotation(模拟) 思路: 只要发现旋转的规律就好了 就是向右旋转的时候,矩阵整体旋转,之后里面的图形成为逆时针旋转$90°$的图形 #include<iostream> #include<algorithm> #include<cstring> using namesp 阅读全文
posted @ 2020-07-08 00:11 overrate_wsj 阅读(299) 评论(0) 推荐(0) 编辑
摘要: A - 饭卡 (HDU - 2546) 0-1背包 思路: 我们肯定希望在余额大于$5$元并且最接近的时候去买那个最贵的 所以问题就转化为只有$m-5$元,在前$n-1$低的物品中尽可能话更多的钱买 这就转化为一个裸的$0-1$背包问题了 #include<iostream> #include<al 阅读全文
posted @ 2020-07-03 21:57 overrate_wsj 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 题意: 给一个序列,进行一下两种操作 $1$.交换下标为$x$与$x+1$的两个数 $2.$.求进行$K$轮冒泡排序之后的逆序对个数 思路: 首先要发现规律,我们假设位置对于$a[i]$左右有$b[i]$个比他大的数,那么每进行一轮冒泡排序,$b[i]=max(b[i]-1,0)$ 那么进行$K$轮 阅读全文
posted @ 2020-07-03 01:17 overrate_wsj 阅读(180) 评论(0) 推荐(0) 编辑
摘要: A. Vowel Count(模拟) 思路: 按照题意统计元音字母个数模拟即可 #include<iostream> #include<algorithm> using namespace std; int main() { int t; cin>>t; while(t--){ string s; 阅读全文
posted @ 2020-07-02 22:48 overrate_wsj 阅读(277) 评论(0) 推荐(0) 编辑
摘要: A. Magical Sticks 思路: 尽可能的凑成长度为$n$的木棍,答案为$(n+1)/2$ #include<iostream> #include<algorithm> using namespace std; int main() { int t; cin>>t; while(t--){ 阅读全文
posted @ 2020-07-02 13:29 overrate_wsj 阅读(426) 评论(0) 推荐(0) 编辑