
STL大法好
Sirius_Ren
▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇自己刮~~~
展开
-
POJ 3253 STL优先队列
题目大意:FJ需要修补牧场的围栏,他需要 N 块长度为 Li 的木头(N planks of woods)。开始时,FJ只有一块无限长的木板,因此他需要把无限长的木板锯成 N 块长度为 Li 的木板,Farmer Don提供FJ锯子,但必须要收费的,收费的标准是对应每次据出木块的长度,比如说测试数据中 5 8 8,一开始,FJ需要在无限长的木板上锯下长度 21 的木板(5+8+8=21),第二次锯下原创 2016-05-15 19:27:51 · 637 阅读 · 0 评论 -
BZOJ 4516 后缀数组+ST+set
写了一半 没了啊啊啊 重新写的 思路: 先不考虑后缀自动机 (我不会啊)那这道题只能用后缀数组了 先把原串倒一下 后缀->前缀 相当于每回在前面加了一个字母 求不同的子串个数 首先 正常的求子串个数我们是会的 SPOJ 705 但是这道题比较坑 它让你每回都输出一下 那只好 维护一个前驱 一个后继 求LCP 取max ans=ans+n-i+1-max(LCP原创 2017-02-01 17:38:30 · 426 阅读 · 0 评论 -
寒假培训1.20 位运算
补码: 负数 ~x+1 正数一样<< >> & ! ~ 运算符… 取某位: (x>>pos)&1 将某些位置为1 x|(1<< i ) 将某些位置为0 x&~(1<< i) 将某些位置取反 x^(1<< i)求1的个数 1.查表 f[i]=f[i>>1]+(i&1) 分段 分成16位 如果内存很小怎么办…… (并没有听懂..)求1的个数的奇偶性 把它拆成两个1原创 2017-01-20 11:32:41 · 353 阅读 · 0 评论 -
BZOJ 2096 单调队列
思路: 偷懒用的STL//By SiriusRen #include <deque> #include <cstdio> using namespace std; struct Node{int id,w;}jy; deque<Node>qmin,qmax; int n,k,xx,t,ans; int main(){ scanf("%d%d",&k,&n); for(int i原创 2017-01-12 17:51:42 · 680 阅读 · 0 评论 -
BZOJ 3544 treap (set)
我只是想找个treap的练习题……每回找到lower_bound 就好啦//By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> using namespace std; #define int long long int n,m,a[200500],sum[200500],jy,ans,root,size;原创 2016-12-09 16:34:20 · 640 阅读 · 0 评论 -
POJ 3050 枚举+dfs+set判重
思路: 枚举+搜一下+判个重 ==AC//By SiriusRen #include <set> #include <cstdio> using namespace std; int a[8][8],xx[]={1,-1,0,0},yy[]={0,0,1,-1}; set<int>s; bool check(int x,int y){ return x>0&&x<6&&y>0&&y<6;原创 2016-10-28 13:12:19 · 616 阅读 · 0 评论 -
POJ 3038 贪心(multiset)
题意: 思路: 1. 贪心 我们考虑肯定是走最近的最合适 想象自己是一个黑一日游的司机: 1.如果有乘客要上车,那么就让他上,收钱! 2.如果超载了,把距目的地最远的几个乘客踢下去,退钱。 3.行驶到下一站 (摘自http://blog.sina.com.cn/s/blog_9d987af5010158ih.html) 多么生动形象….原创 2016-10-28 08:46:32 · 504 阅读 · 0 评论 -
POJ 3629 队列模拟
听说STL会卡T 然后我就试了一发 哈哈哈哈哈哈哈哈哈哈 1000ms卡时过的这很值得我写一发题解了 哈哈哈哈哈哈哈哈哈哈哈哈//By SiriusRen #include <queue> #include <cstdio> #include <algorithm> using namespace std; int n,k,mod,rnd,p,ans[1000050],top; queu原创 2016-10-17 10:02:03 · 718 阅读 · 0 评论 -
POJ 3622 multiset
思路: 放一个链接是我太懒了 http://blog.youkuaiyun.com/mars_ch/article/details/52835978 嗯她教的我(姑且算是吧) (一通乱搞就出来了…)//By SiriusRen #include <set> #include <cstdio> #include <cstring> #include <algorithm> using namespace原创 2016-10-17 09:58:26 · 839 阅读 · 0 评论 -
BZOJ 4236 set乱搞
思路: 取个差 在set里面找 更新 (这个用map更好吧 但是我不会……)//By SiriusRen #include <set> #include <cstdio> #include <algorithm> using namespace std; int n,sum[200050][3],ans; char ch[200050]; struct Node{int x,y,re原创 2016-10-23 20:52:39 · 424 阅读 · 0 评论 -
NOIP2012 T3开车旅行 set+倍增
70分做法: 先预处理出所有点的最近和次近(O(n^2)一遍就OK) 然后暴力求出每个解(O(nm))//By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> #define inf 0x3fffffff using namespace std; int n,x,rech=0x3fffffff,rec,s,m原创 2016-09-07 09:54:14 · 832 阅读 · 0 评论 -
POJ 3187 全排列+杨辉三角(组合数)
思路: next_permutation()加个递推组合数随便搞搞就A了…//By SiriusRen #include <cstdio> #include <algorithm> using namespace std; int n,C[11][11],sum,f[11]; int main(){ scanf("%d%d",&n,&sum); for(int i=1;i<=n;i原创 2016-09-14 23:47:06 · 633 阅读 · 0 评论 -
POJ 3481 set水过
题意:1表示插入客户K,他的优先级是P(相当于大小),2表示输出当前优先级最高的客户(即找出最大值),并且删除。3同理输出最低级的。 这题可以用splay treap AVL SBT …… (可是我并不会) 这里set水过。。#include <set> #include <cstdio> using namespace std; set<pair<int,int> >s; set<pair<原创 2016-06-07 21:49:02 · 555 阅读 · 0 评论 -
POJ 1862
今天的最后一道题了。。 23:59 在POJ上活捉刷题队长一只。 中间就隔了仨人呃呃说正事 题意: 给几个数,合并的代价是 2*sqrt(x1*x2) 问n个数合并的代价最小值。 证明(Discuss里的): 假设有a,b,c 且结果是r 则 r = 2*sqrt(2*sqrt(a*b)*c) 则 r^2/8 = sqrt(a*b*c*c); 若要 r 最小 则 c 一定是原创 2016-05-16 00:07:05 · 536 阅读 · 0 评论 -
BZOJ 4195 程序自动分析
4195: [Noi2015]程序自动分析Description在实现程序自动分析的过程中,常常需要判定一些约束条件是否能被同时满足。考虑一个约束满足问题的简化版本:假设x1,x2,x3,…代表程序中出现的变量,给定n个形如xi=xj或xi≠xj的变量相等/不等的约束条件,请判定是否可以分别为每一个变量赋予恰当的值,使得上述所有约束条件同时被满足。例如,一个问题中的约束条件为:x1=x2,x2=x3原创 2016-05-15 23:30:15 · 937 阅读 · 0 评论 -
BZOJ 3991 set维护dfs序
思路: set按照dfn排序 两点之间的距离可以O(logn)算出来 加一个点-> now ans+=dis(pre,now)+dis(now,next)-dis(pre-next); 删一个点同理 最后加上dis(begin,end)即可//By SiriusRen #include <set> #include <cstdio> #include <cstring> #include原创 2017-03-04 20:56:53 · 438 阅读 · 0 评论