摘要: 1208. 翻硬币 过于简单了 #include <iostream> #include <string> using namespace std; string s1, s2; int ans; void change(int x) { if (x < s1.size()) { s1[x] = ( 阅读全文
posted @ 2025-09-28 15:16 Roin_Long 阅读(7) 评论(0) 推荐(0)
摘要: 116.飞行员兄弟 注释部分是调试中用的部分,忘了void change(int k, vector<PII> &res)中的&导致答案一直为空 #include <iostream> #include <vector> #include <string> #include <cstring> us 阅读全文
posted @ 2025-09-27 15:57 Roin_Long 阅读(4) 评论(0) 推荐(0)
摘要: 93. 递归实现组合型枚举 if (sum + n - u < m) return; 如果当前记录的数据 加上 后面的所有可以被选的数据 时无法达到要求时终止 state记录了哪些数据被选,哪些没被选的 state | 1 << u 选择当前的数据,比如0101 -> 10101 #include 阅读全文
posted @ 2025-09-17 20:21 Roin_Long 阅读(3) 评论(0) 推荐(0)
摘要: 95.费解的开关 用枚举的思想,把第一行先枚举了 (通过: for (int op = 0; op < 32; op ++ ) for (int i = 0; i < 5; i ++ ) if (op >> i & 1) ) 根据第i行去trun第i+1行来改变第i行 trun的改变利用了偏移量来简 阅读全文
posted @ 2025-09-15 14:41 Roin_Long 阅读(4) 评论(0) 推荐(0)
摘要: 92. 递归实现指数型枚举 DFS DFS(node): if node is null: return // 前序遍历:先访问当前节点 visit(node) // 递归遍历所有子节点 for child in node.children: DFS(child) #include <bits/st 阅读全文
posted @ 2025-09-11 15:36 Roin_Long 阅读(2) 评论(0) 推荐(0)
摘要: 二分 P8647 思路 cnt是记录获得巧克力的小朋友的数量 ans是巧克力的边长 找到满足cnt >= k 的,ans的最大值 代码 #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int n, k, h[ 阅读全文
posted @ 2025-08-03 13:34 Roin_Long 阅读(6) 评论(0) 推荐(0)
摘要: 二分 B3880 思路 ans越小cnt越大于m 找到ans的最大值使cnt>=m 代码 #include <bits/stdc++.h> using namespace std; const int N = 1e4 + 10; int n, m, l[N], s[N], ans; // int c 阅读全文
posted @ 2025-08-03 12:16 Roin_Long 阅读(11) 评论(0) 推荐(0)
摘要: 二分 P1918 思路 不复杂二分 代码 #include <iostream> #include <algorithm> using namespace std; typedef struct S{ int x, i; } S; int n, m; S a[100010]; int Binary( 阅读全文
posted @ 2025-08-02 16:42 Roin_Long 阅读(2) 评论(0) 推荐(0)
摘要: 二分 P9497 思路 有 q 组询问,每次给定一个 v,请将矩阵每一行任意重排(可以不重排),最大化最大值不小于 v(也就是说,至少有一个不小于 v 的数)的列数。请输出这个列数。 也就是说: 找到所有数的最大的n个数依次分布在这n列中(因为答案只和每列的最大值相关,所以可以压缩为一维数组) 因此 阅读全文
posted @ 2025-08-02 15:19 Roin_Long 阅读(3) 评论(0) 推荐(0)
摘要: 二分 P1873 思路 二分找到满足获得木材大于M的最大锯片高度 代码 #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int n, m; int a[N]; bool check(int mid) { lo 阅读全文
posted @ 2025-08-01 17:32 Roin_Long 阅读(0) 评论(0) 推荐(0)