随笔分类 -  数据结构

POJ1182 食物链 并查集
摘要:食物链 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 113794 Accepted: 34597 Description 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个 阅读全文
posted @ 2020-02-13 18:45 带你AK,带你飞 阅读(136) 评论(0) 推荐(0)
并查集
摘要:1 #include <iostream> 2 #include <cstdio> 3 4 using namespace std; 5 6 const int max_n = 1000; 7 8 int par[max_n]; 9 int ranks[max_n]; 10 11 void init 阅读全文
posted @ 2020-02-08 20:57 带你AK,带你飞 阅读(96) 评论(0) 推荐(0)
二叉搜索树3
摘要:1 #include <iostream> 2 #include <cstdio> 3 #include <map> 4 #include <string> 5 6 using namespace std; 7 8 // map与multimap 9 // 是键值映射容器 10 // 内部是变体的红 阅读全文
posted @ 2020-02-06 18:07 带你AK,带你飞 阅读(148) 评论(0) 推荐(0)
数据结构--二叉搜索树2
摘要:之前我们实现了简单的二叉搜索树,现在介绍一下,STL中的容器,应对需要使用二叉搜索树的情况其实,大多数时候,用STL中的set就够了,不需要自己实现 1 #include <iostream> 2 #include <cstdio> 3 #include <set> 4 5 using namesp 阅读全文
posted @ 2020-02-06 15:53 带你AK,带你飞 阅读(166) 评论(0) 推荐(0)
数据结构---二叉搜索树
摘要:1 #include <cstdio> 2 #include <iostream> 3 4 using namespace std; 5 6 struct node 7 { 8 int val; 9 node *lch,*rch; 10 }; 11 12 node *insert(node *p,i 阅读全文
posted @ 2020-02-06 14:58 带你AK,带你飞 阅读(261) 评论(0) 推荐(0)
POJ 3253 Fence Repair 贪心 优先级队列
摘要:Fence Repair Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 77001 Accepted: 25185 Description Farmer John wants to repair a small length o 阅读全文
posted @ 2020-02-05 17:35 带你AK,带你飞 阅读(135) 评论(0) 推荐(0)
POJ 2431 Expedition 贪心 优先级队列
摘要:Expedition Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 30702 Accepted: 8457 Description A group of cows grabbed a truck and ventured on 阅读全文
posted @ 2020-02-05 17:06 带你AK,带你飞 阅读(140) 评论(0) 推荐(0)
优先级队列-堆-STL实现
摘要:1 #include <cstdio> 2 #include <iostream> 3 #include <queue> 4 5 using namespace std; 6 7 // 默认是最大堆 8 // 9 10 int main() 11 { 12 priority_queue<int> h 阅读全文
posted @ 2020-02-05 15:44 带你AK,带你飞 阅读(212) 评论(0) 推荐(0)
优先级队列-堆
摘要:1 #include <cstdio> 2 #include <iostream> 3 4 using namespace std; 5 6 const int MAX_N = 1000; 7 8 // 用数组来实现二叉树 9 // 左儿子编号=自己*2 + 1 10 // 右儿子编号=自己*2 + 阅读全文
posted @ 2020-02-05 15:35 带你AK,带你飞 阅读(128) 评论(0) 推荐(0)