codevs 1230【pb_ds】】的更多相关文章

题目链接[http://codevs.cn/problem/1230/] 题意:给出n个正整数,然后有m个询问,每个询问一个整数,询问该整数是否在n个正整数中出现过. 题解:很简单的一道题,可以选择用map,unordered_map,字典树等等进行映射,就可以了.也可以用pb_ds的hash_table进行映射. #include<cstdio> #include<cstring> #include<algorithm> #include<ext/pb_ds/a…
线段树套pb_ds里的平衡树,在洛谷OJ上测试,后三个测试点TLE #include<cstdio> #include<algorithm> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #define N 50010 #define INF 2147483647 using namespace std; using namespace __gnu_pb…
需要用数组记录编号为i的书的位置,和位置i处的书的编号. Code: #include<cstdio> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_cxx; using namespace __gnu_pbds; tree<int,null_type,less<int…
每次来的如果是人,且宠物数不为零,就从宠物中选出一个与其差距最小的,累加答案:若为零,就把他放入另一个集合里. 如果是宠物,则同上. 各种平衡树都可过,我蛋疼地用了pb_ds. Code: #include<cstdio> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_cxx; u…
STL裸题,线下AC,bzoj无限RE ing…… #include<cstdio> #include<cctype> #include<iostream> #include<string> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_cxx;…
用并查集维护联通性.对每个联通块维护一个平衡树.合并时启发式合并.比较懒,用了pb_ds. #include<cstdio> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_cxx; using namespace __gnu_pbds; tree<]; tree<int…
题目链接:网络管理 好久没写这种类型的题了--手都生了-- 一句话题意:树上带修改的区间\(k\)大数.这题面怎么有点眼熟 显然树上的题目我们可以先在序列上考虑一下.区间带修改的区间\(k\)大数有两种做法(我只知道两种):一种是树套树,一种是整体二分.这道题感觉如果是树套树的话加到树上会很麻烦,于是就写了整体二分.(不过感觉好像CDQ分治啊 序列问题和普通的整体二分没有什么区别,只是要注意一个修改操作需要拆成两个,一个操作是把原来的数删掉,下一个才是改为这个数.这样的话就可以保证一个元素的加入…
题目描述 Description 熊大妈的奶牛在小沐沐的熏陶下开始研究信息题目.小沐沐先让奶牛研究了最长上升子序列,再让他们研究了最长公共子序列,现在又让他们要研究最长公共上升子序列了.小沐沐说,对于两个串A,B,如果它们都包含一段位置不一定连续的数字,且数字是严格递增的,那么称这一段数字是两个串的公共上升子串,而所有的公共上升子串中最长的就是最长公共上升子串了.奶牛半懂不懂,小沐沐要你来告诉奶牛什么是最长公共上升子串.不过,只要告诉奶牛它的长度就可以了. 输入描述 Input Descript…
ARTS: Algrothm: leetcode算法题目 Review: 阅读并且点评一篇英文技术文章 Tip/Techni: 学习一个技术技巧 Share: 分享一篇有观点和思考的技术文章 Algorithm [leetcode]Unique Morse Code Words https://leetcode.com/problems/unique-morse-code-words/ 1)problem International Morse Code defines a standard e…
[动规]爱与愁的心痛 [动规]编辑距离 [动规]采药 [动规]创意吃鱼法 [动规]过河卒 [动规]开心的金明 [动规]旅行 [动规]骑士游历 [动规]数字三角形 [动规]最长连号 [动规]装箱问题 [递归]对称二叉树 [递归]汉诺塔游戏 [递推]月落乌啼算钱 [模拟]爱与愁的一千个伤心的理由 [模拟]弹珠游戏 [模拟]高精度练习之加法 [模拟]高精度练习之减法 [模拟]立体图 [模拟]魔法照片 [模拟]谁拿了最多奖学金 [模拟]图书管理员 [模拟]玩具谜题 [模拟]无线网络发射器选址 [模拟]压…