摘要: pb_ds库的讲解和应用举例 pb_ds 是GNU-C++自带的一个C++的扩展库,其中实现了很多数据结构,比STL里面的功能更强大 哈希表 需要的头文件: #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/hash_policy. 阅读全文
posted @ 2025-08-28 15:56 张诗羽 阅读(26) 评论(0) 推荐(0)
摘要: 库函数 math.h cctype string.h math.h 三角函数 double sin (double); double cos (double); double tan (double); 反三角函数 double asin (double); 结果介于[-PI/2, PI/2] do 阅读全文
posted @ 2025-08-28 15:33 张诗羽 阅读(7) 评论(0) 推荐(0)
摘要: 双指针 双指针顾名思义,就是同时使用两个指针,在序列、链表结构上指向的是位置,在树、图结构中指向的是节点,通过或同向移动,或相向移动来维护、统计信息。 博文 快慢指针 维护区间信息 leetcode 713.乘积小于k的子数组 class Solution { public: int numSuba 阅读全文
posted @ 2025-08-08 23:08 张诗羽 阅读(7) 评论(0) 推荐(0)
摘要: #include <iostream> #include <cstring> #include <algorithm> #include <string> using namespace std; const int MAXN = 1000010; int m, n; string s, p; in 阅读全文
posted @ 2025-07-12 14:36 张诗羽 阅读(12) 评论(0) 推荐(0)
摘要: #include <iostream> #include "stack.hpp" #include "vector.hpp" using namespace std; typedef enum { UNDISCOVERED, DISCOVERED, VISITED } VStatus; typede 阅读全文
posted @ 2025-07-07 11:53 张诗羽 阅读(7) 评论(0) 推荐(0)
摘要: Prim 基于优先队列 #include <iostream> #include <vector> #include <algorithm> #include <cstring> #include <queue> using namespace std; #define INF 1e9 const 阅读全文
posted @ 2025-07-07 11:50 张诗羽 阅读(12) 评论(0) 推荐(0)
摘要: dijkstra #include <iostream> #include <vector> #include <queue> #include <cstring> using namespace std; int n, m, s, a, b, c; const int MAXN = 100010; 阅读全文
posted @ 2025-07-05 20:12 张诗羽 阅读(10) 评论(0) 推荐(0)
摘要: Kahn算法 #include <iostream> #include <cstring> #include <algorithm> #include <queue> using namespace std; const int N = 100010; int n, m, a, b; vector< 阅读全文
posted @ 2025-07-05 17:21 张诗羽 阅读(7) 评论(0) 推荐(0)
摘要: #include <iostream> #include "stack.hpp" using namespace std; #define BinNodePosi(T) BinNode<T> * #define stature(p) ((p) ? (p)->height : -1) typedef 阅读全文
posted @ 2025-07-03 16:41 张诗羽 阅读(13) 评论(0) 推荐(0)
摘要: stack #include "vector.hpp" template <typename T> class Stack : public Vector<T> { public: void push(T const &e) { insert(size(), e); } T pop() { retu 阅读全文
posted @ 2025-07-02 17:36 张诗羽 阅读(13) 评论(0) 推荐(0)