上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 45 下一页
摘要: 简单题,输入有技巧 注意要在正式读入之前先用一个getline把那个回车读入了,因为cin不会处理回车。 #include <iostream> #include <algorithm> #include <stdlib.h> #include <cstring> #include <sstream 阅读全文
posted @ 2023-11-13 16:39 Gold_stein 阅读(22) 评论(0) 推荐(0)
摘要: 用一个队列模拟,每次都只处理队头位置的差异 #include <iostream> #include <algorithm> #include <stdlib.h> #include <cstring> using namespace std; const int N = 1005; char s[ 阅读全文
posted @ 2023-11-13 15:29 Gold_stein 阅读(17) 评论(0) 推荐(0)
摘要: #include <iostream> #include <algorithm> #include <stdlib.h> #include <string> using namespace std; const int N = 9, M = 1 << N; char str[100]; int Ro 阅读全文
posted @ 2023-11-11 23:52 Gold_stein 阅读(27) 评论(0) 推荐(0)
摘要: 这类分组问题无非就是两种搜索顺序: 1.对于每个元素,枚举它可能分配到哪一个组 2.对于每个组,枚举它可能容纳哪些元素 这道题先把猫的体重从大到小排序,可以减小状态空间: #include <iostream> #include <algorithm> #include <stdlib.h> usi 阅读全文
posted @ 2023-11-08 11:19 Gold_stein 阅读(18) 评论(0) 推荐(0)
摘要: 因为重合部分越短,每次增加的长度就越长,所以如果有多种连接方式,就选择重合部分最短的那一类。 因为要多次判断重合部分的长度,所以可以在dfs之前先预处理打表一遍所有字符串相互的重合长度。 #include <iostream> #include <algorithm> #include <stdli 阅读全文
posted @ 2023-11-06 17:26 Gold_stein 阅读(20) 评论(0) 推荐(0)
摘要: 这题通过组合方式来枚举,可以避免组内冗余,但是无法避免不同组之间的冗余,为避免后者,可以加一个判断来避免冗余: if (gcnts == 0) return; 完整代码: #include <iostream> #include <algorithm> #include <vector> using 阅读全文
posted @ 2023-11-03 22:40 Gold_stein 阅读(19) 评论(0) 推荐(0)
摘要: 注意是否需要回溯 #include <iostream> #include <algorithm> using namespace std; const int N = 15; int sx, sy, n, m, t, ans; bool vis[N][N]; int dx[] = {-2,-1,1 阅读全文
posted @ 2023-11-02 16:14 Gold_stein 阅读(14) 评论(0) 推荐(0)
摘要: 这道题注意要记录的是总步数,而不是当前步数 #include <iostream> #include <cstring> using namespace std; const int N = 105; char g[N][N]; int k, n; bool vis[N][N]; int sx, s 阅读全文
posted @ 2023-11-01 17:50 Gold_stein 阅读(17) 评论(0) 推荐(0)
摘要: dfs模板 #include <iostream> #include <cstring> using namespace std; const int N = 105; char g[N][N]; int k, n; bool vis[N][N]; int sx, sy, ex, ey; int d 阅读全文
posted @ 2023-11-01 11:33 Gold_stein 阅读(23) 评论(0) 推荐(0)
摘要: 错误的等级区间限制: for(int st=l_min;st+Limit<=l_max;st++) 正确的等级区间限制: for(int st=l_min;st<=l_max;st++) 上限超了是没有任何影响的 完整代码: #include <stdio.h> #include <stdlib.h 阅读全文
posted @ 2023-10-26 09:41 Gold_stein 阅读(17) 评论(0) 推荐(0)
上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 45 下一页