03 2021 档案
摘要:5696. 统计异或值在范围内的数对有多少 难度困难3收藏分享切换为英文接收动态反馈 给你一个整数数组 nums (下标 从 0 开始 计数)以及两个整数:low 和 high ,请返回 漂亮数对 的数目。 漂亮数对 是一个形如 (i, j) 的数对,其中 0 <= i < j < nums.len
阅读全文
摘要:第一次成功 \(AK\) \(leetcode\) 周赛,决定写篇博客记录一下。 这场周赛确实相对简单一些。 5701. 仅执行一次字符串交换能否使两个字符串相等 给你长度相等的两个字符串 s1 和 s2 。一次 字符串交换 操作的步骤如下:选出某个字符串中的两个下标(不必不同),并交换这两个下标所
阅读全文
摘要:链表版字典树 class Trie { Trie* next[26]; int num; public: Trie() { for (int i = 0; i < 26; ++i) next[i] = NULL; num = 0; } void insert(char *s) { Trie *p =
阅读全文
摘要:hdu1251统计难题 链表版字典树: #include <cstdio> #include <string> using namespace std; class Trie { Trie* next[26]; int num; public: Trie() { for (int i = 0; i
阅读全文
摘要:leetcode 5699 从第一个节点出发到最后一个节点的受限路径数 所谓从节点 \(1\) 到节点 \(n\) 的受限路径,就是从 \(1\) 号节点出发,每一步必须到达离 \(n\) 号节点更近的节点。 令 \(dp_i\) 为从节点 \(i\) 到节点 \(n\) 的受限路径数,显然 \(d
阅读全文
摘要:试题A: 门牌制作 问 \(1\sim 2020\) 中包含多少个字符 \(2\) 。 暴力枚举。 #include <cstdio> int getCnt(int x) { int cnt = 0; while (x) { if (x%10 == 2) ++cnt; x /= 10; } retu
阅读全文
摘要:poj3468 A Simple Problem with Integers 线段树: 区间加数 区间求和 #include <cstdio> #include <iostream> #include <algorithm> #include <vector> using namespace std
阅读全文
摘要:I Hate It 线段树: 单点修改 查询区间最小值 #include <cstdio> #include <iostream> #include <algorithm> #include <vector> using namespace std; typedef long long LL; /*
阅读全文
摘要:并查集(Disjoint Set Union)模板 #include <vector> using namespace std; /** * Disjoint Set Union */ class DSU { vector<int> s; int cnt; // 记录集合个数 public: DSU
阅读全文
摘要:POJ - 1611The Suspects 并查集。 将每个组的学生进行合并,最后 \(0\) 号学生所在集合的学生个数即为答案。 #include <cstdio> #include <vector> using namespace std; /** * Disjoint Set Union *
阅读全文
摘要:POJ - 2236Wireless Network 并查集。 每次修理计算机,遍历可以与之相连的计算机并进行合并。时间复杂度 \(O(n\log n)\) 。最多只用修理 \(n\) 次。 每次测试连通性,判断根节点是否相同,时间复杂度 \(O(1)\) 。最多不过 \(3e5\) 次测试。 总时
阅读全文

浙公网安备 33010602011771号