03 2021 档案
-
动态规划--状态压缩
摘要:https://www.acwing.com/problem/content/293/ 给定一个空矩阵,问用1*2的矩形将其填满存在多少种方案。 可以只考虑一种,如果横的都已经确定了,那么竖的只有0或者1种放法,所以只考虑横的就好了(只考虑竖的也行) 暴搜复杂度为O(N! * M!),所以只能考虑动 阅读全文
-
AcWing每日一题--跳一跳
摘要:https://www.acwing.com/problem/content/3260/ 水题。 每次记录上一次连续多少次跳到了中心即可。 1 #include<iostream> 2 using namespace std; 3 int main(void){ 4 int res=0,point= 阅读全文
-
AcWing每日一题--折点计数
摘要:https://www.acwing.com/problem/content/3230/ 利用标记变量。 1 #include<iostream> 2 using namespace std; 3 const int N=1010; 4 int a[N]; 5 int main(void){ 6 i 阅读全文
-
AcWing每日一题--最大波动
摘要:https://www.acwing.com/problem/content/3235/ 水题。 1 #include<iostream> 2 #include<cmath> 3 using namespace std; 4 int main(void){ 5 int n; 6 cin>>n; 7 阅读全文
-
AcWing每日一题--画图
摘要:https://www.acwing.com/problem/content/3206/ 水题。 1 #include<iostream> 2 using namespace std; 3 bool st[110][110]; 4 int main(void){ 5 int n; 6 cin>>n; 阅读全文
-
AcWing每日一题--Z字形扫描
摘要:https://www.acwing.com/problem/content/3211/ 直接看成两个三角形(略显复杂) 1 #include<iostream> 2 using namespace std; 3 const int N=500; 4 int a[N][N]; 5 int main( 阅读全文
-
动态规划--记忆化搜索
摘要:https://www.acwing.com/problem/content/903/ 记忆化搜索经典题目,滑雪。 只能从高的地方往低的地方滑,问最多能滑多少个点。 如果这个方程用循环来写的话,听说会非常非常麻烦(反正我不会) 所以就有了记忆化搜索。 1 #include<iostream> 2 # 阅读全文
-
leetcode周赛 233
摘要:A:水题,数据范围较小,直接暴力模拟。 1 class Solution { 2 public: 3 bool check(vector<int> a,int i,int j ){ 4 for(int k=i+1;k<=j;k++){ 5 if(a[k]<=a[k-1]){ 6 return fal 阅读全文
-
leetcode每日一题--逆波兰表达式求值
摘要:https://leetcode-cn.com/problems/evaluate-reverse-polish-notation/ 逆波兰表达式也就是后缀表达式,直接通过栈即可求出答案。 难的不是逆波兰表达式的求值,难的是将中缀表达式转化为后缀表达式。 1 class Solution { 2 p 阅读全文
-
牛客 小白月赛32
摘要:A:枚举所有可能的情况,判断能否组成两个三角形。 1 #include<iostream> 2 #include<vector> 3 using namespace std; 4 bool three_one(int a){ 5 int cnt0=0,cnt1=0; 6 for(int i=0;i< 阅读全文
-
动态规划--树形DP
摘要:https://www.acwing.com/problem/content/287/ 所谓树形DP,也就是关系的两边变成了树的上层和下层。 1 #include<iostream> 2 #include<cstring> 3 using namespace std; 4 const int N=6 阅读全文
-
leetcode周赛 232
摘要:A:水题,给定两个字符串,问能否只交换一次使得两字符串相等。 解法1:记录两字符串不相等的位置。 1 class Solution { 2 public: 3 bool areAlmostEqual(string s1, string s2) { 4 int n=s1.length(); 5 int 阅读全文
-
Codeforces Round #707
摘要:A:模拟题,每次进站加上应该要的时间和延迟的时间 每次等待的时候需要题给定的两个条件都满足。 注意:最后一站不需要等待,所以需要单独考虑。 1 #include<cstring> 2 #include<algorithm> 3 #include<iostream> 4 using namespace 阅读全文
-
动态规划--数位DP
摘要:https://www.acwing.com/problem/content/340/ 1 #include<iostream> 2 #include<vector> 3 using namespace std; 4 int get(vector<int> v,int l,int r){ 5 int 阅读全文
-
Codeforces Round #706 A~C
摘要:A:给了一个比较复杂的定义,但是仔细读了之后就会发现问的就是字符串s的回文长度是否大于等于k,例如abqewba的回文长度是2. 1 #include<algorithm> 2 #include<iostream> 3 using namespace std; 4 5 int main(void){ 阅读全文
-
贪心--区间问题
摘要:1、区间选点问题 https://www.acwing.com/problem/content/907/ 给定n个区间,选择尽量少的点使得每个区间都至少包含一个点,问最少的点的数量是多少。 1 #include<algorithm> 2 #include<iostream> 3 using name 阅读全文
-
leetcode周赛 231
摘要:A:水题。 解法1:首先确定一个全为1的串,之后如果在出现1,就返回false 1 class Solution { 2 public: 3 bool checkOnesSegment(string s) { 4 bool flag=true; 5 int n=s.size(); 6 for(int 阅读全文
-
动态规划--计数类DP
摘要:https://www.acwing.com/problem/content/902/ 整数划分问题,给定一个正整数n,问有多少种方案使得n=x1+x2+...+xn,不考虑顺序。 解法1:利用完全背包的模型,将1~n每一个数字看成一个物品。 1 #include<iostream> 2 using 阅读全文