04 2015 档案

摘要:其实可以优化读入函数的,但考虑到现在的数据多么坑是吧,就酱吧……万一不给你最后那个字符不就T了…… 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std... 阅读全文
posted @ 2015-04-27 21:50 AI_Believer 阅读(234) 评论(0) 推荐(0)
摘要:传送门:http://oj.cnuschool.org.cn/oj/home/problem.htm?problemID=983WZJ的数据结构(七)难度级别:C; 运行时间限制:1000ms; 运行空间限制:51200KB; 代码长度限制:2000000B试题描述给你一棵N个节点的无根树,每个点有... 阅读全文
posted @ 2015-04-26 17:11 AI_Believer 阅读(242) 评论(0) 推荐(0)
摘要:传送门:http://oj.cnuschool.org.cn/oj/home/problem.htm?problemID=1720604悲剧文本难度级别:B; 运行时间限制:1000ms; 运行空间限制:51200KB; 代码长度限制:2000000B试题描述 你有一个键盘,键盘上所有的键都能正常使... 阅读全文
posted @ 2015-04-25 22:28 AI_Believer 阅读(425) 评论(0) 推荐(0)
摘要:传送门:http://oj.cnuschool.org.cn/oj/home/solution.htm?solutionID=3545420603矩阵链乘难度级别:B; 运行时间限制:1000ms; 运行空间限制:51200KB; 代码长度限制:2000000B试题描述 输入n个矩阵的维度和一些矩阵... 阅读全文
posted @ 2015-04-25 21:53 AI_Believer 阅读(374) 评论(0) 推荐(0)
摘要:传送门:http://oj.cnuschool.org.cn/oj/home/problem.htm?problemID=1520602铁轨难度级别:B; 运行时间限制:1000ms; 运行空间限制:51200KB; 代码长度限制:2000000B试题描述 某城市有一个火车站,铁轨铺设如图所示,有n... 阅读全文
posted @ 2015-04-25 20:08 AI_Believer 阅读(257) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int maxn=100000+10,INF=-1u>>1; 7 int v[maxn],maxv[maxn],minv[maxn],... 阅读全文
posted @ 2015-04-25 18:18 AI_Believer 阅读(198) 评论(0) 推荐(0)
摘要:传送门:http://oj.cnuschool.org.cn/oj/home/problem.htm?problemID=313试题描述:WZJ的公司放假了!为了保证假期期间公司的安全,WZJ决定雇佣一些人来看守公司。有M个大学生来应聘,他们想要的工资是Ci元,可以为WZJ从第Si天到Ti天看守公司... 阅读全文
posted @ 2015-04-21 21:09 AI_Believer 阅读(149) 评论(0) 推荐(0)
摘要:传送门:http://oj.cnuschool.org.cn/oj/home/problem.htm?problemID=1042试题描述:LZJ有一个问题想问问大家。他在写函数时有时候很头疼,如他写了这样几个函数:void f1(){ f2(); f3();}void f2(){ f3();}vo... 阅读全文
posted @ 2015-04-21 20:42 AI_Believer 阅读(232) 评论(0) 推荐(0)
摘要:传送门:http://oj.cnuschool.org.cn/oj/home/problem.htm?problemID=200试题描述:地球人都知道Fibonicca数列:1 1 2 3 5 8 -----输入两个正整数L,R,输出Fibonicca数列第L项加到第R项的结果,因为答案可能很大,请... 阅读全文
posted @ 2015-04-21 20:34 AI_Believer 阅读(213) 评论(0) 推荐(0)
摘要:传送门:http://oj.cnuschool.org.cn/oj/home/problem.htm?problemID=312试题描述:给你一个大小为N的int数组A。请你统计有多少数对(Ai,Aj)满足iAj并输出。输入:第一行为N,表示数组A的大小。第二行为N个数Ai,两两之间用一个空格分隔。... 阅读全文
posted @ 2015-04-21 20:09 AI_Believer 阅读(356) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 #define inf -1u>>1 6 using namespace std; 7 const int maxn=50000+10; 8 struct Tedge{int x,y,dis... 阅读全文
posted @ 2015-04-21 20:03 AI_Believer 阅读(159) 评论(0) 推荐(0)
摘要:【转】http://www.cnblogs.com/frog112111/archive/2013/05/19/3087648.html讲得不是一般的好:Fibonacci数列:F(0)=Fibonacci数列:F(0)=1 , F(1)=1 , F(n)=F(n-1)+F(n-2)我们以前快速求F... 阅读全文
posted @ 2015-04-20 22:10 AI_Believer 阅读(224) 评论(0) 推荐(0)
摘要:DescriptionMirko works on a pig farm that consists of M locked pig-houses and Mirko can't unlock any pighouse because he doesn't have the keys. Custom... 阅读全文
posted @ 2015-04-19 20:21 AI_Believer 阅读(313) 评论(0) 推荐(0)
摘要:经过大量测试,除法哈希对于随机数据确实快且稳定,平均110ms以下;乘法哈希表紧随其后110ms左右;全域哈希很不稳定,130ms左右大浮动;带上二次探查&线性探查完全没有变化。开放寻址较开链法会慢一些(没有删除时),但有时候会快一大截,速度很大程度上取决于数据。So,请老老实实的用除法开链,算导只... 阅读全文
posted @ 2015-04-19 15:26 AI_Believer 阅读(142) 评论(0) 推荐(0)
摘要:Spfa: 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int maxn=100000+10,INF=-1u>>1; 8 struct Tedge{int x,y,w,ne... 阅读全文
posted @ 2015-04-17 22:34 AI_Believer 阅读(173) 评论(0) 推荐(0)
摘要:先来LCA的: 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int maxn=200000+10; 7 struct Tedge{int x,y,next;}adj[maxn*2];int fc... 阅读全文
posted @ 2015-04-15 22:01 AI_Believer 阅读(140) 评论(0) 推荐(0)
摘要:先打上代码以后更新解释 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define REP(i, s, n) for(int i = s; i = s; i --) 8 #define LOW for(; x; x -=... 阅读全文
posted @ 2015-04-14 22:56 AI_Believer 阅读(213) 评论(0) 推荐(0)
摘要:Splay的区间维护还是很机智的,不好写是真的。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define REP(i, s, n) for(int i = s; i = s; i --) 8 using... 阅读全文
posted @ 2015-04-14 21:46 AI_Believer 阅读(189) 评论(0) 推荐(0)
摘要:write无力吐槽了 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define REP(i, s, n) for(int i = s; i = s; i --) 8 using namespace std; 9 inl... 阅读全文
posted @ 2015-04-13 23:24 AI_Believer 阅读(217) 评论(0) 推荐(0)
摘要:传送门:http://oj.cnuschool.org.cn/oj/home/addSolution.htm?problemID=955试题描述:CHX有一个问题想问问大家。给你一个长度为N的数列A,请你找到两个位置L,R,使得A[L]、A[L+1]、……、A[R]中没有重复的数,输出R-L+1的最... 阅读全文
posted @ 2015-04-13 23:01 AI_Believer 阅读(307) 评论(2) 推荐(1)
摘要:越来越觉得主席树这个东西需要意会了……太TM深奥了TAT (๑•̀ㅂ•́)و✧ 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define REP(i, s, n) for(int i = s; i = s; i --)... 阅读全文
posted @ 2015-04-13 21:32 AI_Believer 阅读(425) 评论(0) 推荐(0)
摘要:注意:就算冲突了也要修改我们的num,因为这个调了一下午Σ( ° △ °|||)︴哈希链表会好一点,因为我们要的是连续的指针,就不用映射map了。(TAT) 1 #include 2 #include 3 #include 4 #include 5 #include 6 #de... 阅读全文
posted @ 2015-04-12 21:20 AI_Believer 阅读(170) 评论(0) 推荐(0)
摘要:记得bl[0] = bl[n+1] = 一个很奇怪的数 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define REP(i, s, n) for(int i = s; i = s; i --) 8 #define i... 阅读全文
posted @ 2015-04-12 15:54 AI_Believer 阅读(167) 评论(0) 推荐(0)
摘要:WZJ的数据结构(三)难度级别:B; 运行时间限制:3000ms; 运行空间限制:51200KB; 代码长度限制:2000000B试题描述请你设计一个数据结构,完成以下功能:给定一个大小为N的整数组A,M次询问。每次询问给你i,j两个参数,求Ai至Aj中最大的数。输入第一行为两个正整数N,M。第二行... 阅读全文
posted @ 2015-04-12 14:17 AI_Believer 阅读(238) 评论(0) 推荐(0)
摘要:以下转自http://prominences.weebly.com/1/post/2013/02/1.html可持久化线段树,也叫作函数式线段树,也就是主席树,(。。。因为先驱就是fotile主席。。Orz。。。)网上的教程很少啊,有的教程写得特别简单,4行中文,然后就是一篇代码~~这里,我将从查找... 阅读全文
posted @ 2015-04-12 13:21 AI_Believer 阅读(287) 评论(0) 推荐(0)
摘要:2015-4-12Dinic * 1 (AC)静态主席树 * 1 (AC)treap * 1 (TLE * 2 + AC ,insert的两个maintain写反了)ST表 * 1 (AC) 阅读全文
posted @ 2015-04-11 23:54 AI_Believer 阅读(193) 评论(0) 推荐(0)
摘要:传送门:http://oj.cnuschool.org.cn/oj/home/problem.htm?problemID=1046试题描述:WZJ又有一个问题想问问大家。WZJ用数据生成器生成了一个虚拟旅游区。这个旅游区由N个城市构成,标号从1到N,这些城市之间由M条双向道路连接。其中每个城市有一个... 阅读全文
posted @ 2015-04-11 21:26 AI_Believer 阅读(349) 评论(0) 推荐(0)
摘要:比链表版快一点吧 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define REP(s, n) for(int i = s; i <= n; i ++) 7 using namespace std; 8... 阅读全文
posted @ 2015-04-10 22:25 AI_Believer 阅读(290) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #define inf 0x3f3f3f3f 8 const int maxn = 200; 9 int n, m, pre[maxn], edge[... 阅读全文
posted @ 2015-04-08 00:09 AI_Believer 阅读(122) 评论(0) 推荐(0)
摘要:1 int s[N],a[N];//离线瞎搞 2 int n,q,ans[M]; 3 int nxt[N]; 4 mapmp; 5 struct Question{ 6 int l,r,id; 7 bool operator0;i-=lowbit(i))17 re... 阅读全文
posted @ 2015-04-08 00:06 AI_Believer 阅读(147) 评论(0) 推荐(0)
摘要:1 mapmp;//在线主席树 2 int a[N],tot,n,q; 3 int T[M],lson[M],rson[M],val[M]; 4 int bulid(int l,int r){ 5 int root=tot++; 6 val[root]=0; 7 int ... 阅读全文
posted @ 2015-04-08 00:04 AI_Believer 阅读(140) 评论(0) 推荐(0)
摘要:【转】这一节涉及数学超级多,各种数论知识,各种不明觉厉! 看了几遍,才勉强看懂一些,所以这篇稍微简单的介绍着两种hash table, 免得瞎说说错了。这一讲的主要知识点是:1. 全域哈希及构造 2. 完美哈希1. 全域哈希及构造介绍全域哈希之前,要先讨论一下普通哈希的一个缺点。 举个charle... 阅读全文
posted @ 2015-04-06 15:12 AI_Believer 阅读(535) 评论(0) 推荐(0)
摘要:【转】主席树:对于序列的每一个前缀建一棵以序列里的值为下标的线段树(所以要先离散化),记录该前缀序列里出现的值的次数;记离散后的标记为1~n; (下面值直接用1~n代替;)对于区间[x,y]的第k大的值,那么从root[x-1],root[y]开始,t=root[y].[1,mid]-root[x-... 阅读全文
posted @ 2015-04-05 20:38 AI_Believer 阅读(153) 评论(0) 推荐(0)
摘要:注意输入v要在建根的前面。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 const int maxn = 1... 阅读全文
posted @ 2015-04-05 11:19 AI_Believer 阅读(324) 评论(0) 推荐(0)
摘要:Setv[]上来要全弄成负的。query里的sum别忘了加一。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int maxn = 100000 + ... 阅读全文
posted @ 2015-04-04 23:18 AI_Believer 阅读(228) 评论(0) 推荐(0)
摘要:注意容易写错的:update和query的闭开区间及query的递归。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int maxn = 1000000 + 10... 阅读全文
posted @ 2015-04-04 20:56 AI_Believer 阅读(155) 评论(0) 推荐(0)
摘要:注意root的v要给一个很奇怪的数,null的s是0。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 cons... 阅读全文
posted @ 2015-04-04 20:08 AI_Believer 阅读(147) 评论(0) 推荐(0)
摘要:不断用BFS构造分层网络,用DFS增广。中途用取指的cur优化DFS。Dinic封装模板: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8... 阅读全文
posted @ 2015-04-04 18:10 AI_Believer 阅读(146) 评论(0) 推荐(0)
摘要:图的遍历分为BFS宽度优先遍历和DFS深度优先遍历两种,前者以队列为载体,后者以递归为载体。邻接表模板:BFS 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int maxn = 1000... 阅读全文
posted @ 2015-04-04 17:08 AI_Believer 阅读(181) 评论(0) 推荐(0)
摘要:首先,AC自动机不是Accept自动机,别以为把这段代码复制到OJ上就全都自动AC了……其实这玩意是Aho-Corasick 造出来的,所以你懂的。那么这玩意能干嘛咧?•字符串的匹配问题•多串的匹配问题※看不懂吧?解释一下:例如给几个单词 acbs,asf,dsef,再给出一个 很长的文章,acbs... 阅读全文
posted @ 2015-04-03 20:42 AI_Believer 阅读(293) 评论(0) 推荐(0)
摘要:表示图的一种方法,用哈希链存储每一个顶点到其子节点的边信息。对于每一条边,我们存储两个顶点u,v及边的权值w。拿图论基本图举例:上图有11条边。我们从0开始为这些边标号:先给出数组的存储方法(可能错误):用first[i]表示第编号为i的节点的第一个子节点的编号,这个子节点的选取是任意的。用next... 阅读全文
posted @ 2015-04-02 22:13 AI_Believer 阅读(315) 评论(0) 推荐(0)
摘要:传送门:http://oj.cnuschool.org.cn/oj/home/problem.htm?problemID=1037试题描述:信息学社团已经逐渐发展壮大,成员也越来越多。现在,有n个同学有了关于信息学的问题,公务繁忙的杨老师决定派出n个小助手来帮助他们解答问题。现在问题来了,每个小助手... 阅读全文
posted @ 2015-04-02 21:08 AI_Believer 阅读(326) 评论(0) 推荐(0)
摘要:未加强传送门0601:http://oj.cnuschool.org.cn/oj/home/addSolution.htm?problemID=571加强传送门0602:http://oj.cnuschool.org.cn/oj/home/problem.htm?problemID=572试题描述:... 阅读全文
posted @ 2015-04-02 19:55 AI_Believer 阅读(231) 评论(0) 推荐(0)