
模板
pcccc0616
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LCA倍增标程
LCA倍增标程#include<iostream>#include<cstdio>#include<cmath>using namespace std;int n,m,s,x,y;struct {int to,next;}a[1000010];int head[500010],deep[500010],zx[500010][20],tot;void build(int x,int y)原创 2017-02-13 11:43:35 · 266 阅读 · 0 评论 -
SPFA模板
模板题 代码#include<iostream>#include<cstdio>int n,m,to[100001],nxt[100001],head[100001],e,hed,tail,dis[100001],stack[100001];int cost[100001],x,y;bool in[100001];using namespace std;inline void ad原创 2017-08-10 07:59:40 · 883 阅读 · 0 评论 -
排列组合
小比琪的屁屁 排列 组合 排列有顺序,组合没顺序;就是这么简单!!公式 很好理解的 1:从m中选n个,假设m个中有一个是x,所有的情况就可分为选x和不选x,对于选x的情况,就相当于从m-1个里选n-1个,对于不选x的情况,就相当于从m-1里选n个 2:c(n,m)=c(m-n,m)(假设选为涂红色,不选为涂白色) 从m个里选n个的涂红色总情况数等于从m个里选m-原创 2017-08-02 21:06:19 · 616 阅读 · 0 评论 -
求有向图的强连通分量(scc):Tarjan算法
Tarjan#include<iostream>#include<vector>using namespace std;const int MAX=10001;int Stop;//栈中的元素个数int cnt;//记录连通分量的个数int visitNum;//记录遍历的步数int DFN[MAX]; //记录节点u第一次被访问时的步数int LOW[MAX]; //记录与节点u和u的转载 2017-02-15 21:08:15 · 399 阅读 · 0 评论 -
强连通分量
讲解一道模板题牛的舞会The Cow Prom#include<iostream>#include<cstdio>using namespace std;int n,m,to[1000001],nxt[100001],head[1000001];int edge,dfn[100001],low[100001],xx,yy,ans,top,time;bool in[1000001];int原创 2017-07-28 15:30:39 · 336 阅读 · 0 评论 -
RMQ求LCA
落谷模板#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<string>#define MAXN 1010001using namespace std;int n,m,to[MAXN],nxt[MAXN],s,head[MAXN],e,pos[MAXN],dfn[MAXN],u,原创 2017-09-07 21:40:35 · 302 阅读 · 0 评论 -
map用法
#include <map>#include <iostream>using namespace std;int main(){ map< string,int > a; cout<<"插入:"<<endl; a["April"]=112;//插入 cout<<a["April"]<<endl; cout<<endl; cout<<"查询原创 2017-10-24 10:22:40 · 421 阅读 · 0 评论 -
bitset
//http://blog.youkuaiyun.com/chaiwenjun000/article/details/71154235#include<iostream>#include<cstdio>#include<bitset>using namespace std;bitset<10> a;bitset<10> b;int main(){ a.set(); cout<<a原创 2017-10-24 11:14:43 · 479 阅读 · 0 评论 -
priority queue
//大根堆 #include<iostream>#include<cstdio>#include<queue>using namespace std;priority_queue<int>q;int main(){ q.push(1); q.push(2); q.push(3); while(q.size()) { cout<<q原创 2017-10-24 11:16:18 · 272 阅读 · 0 评论 -
vector
#include<iostream>#include<cstdio>#include<vector>using namespace std;vector<int> a[100];int main(){ for(int i=1;i<=200;i++) { a[1].push_back(i); } a[1].pop_back(); co原创 2017-10-24 11:16:51 · 281 阅读 · 0 评论 -
(方法)枚举2^k所有情况
#include<iostream>#include<cstdio>using namespace std;int t,n,m,a[101][101],k,ans;int s1,s2,s;void get(){ int pc=min(k+1,m);ans=2e9; for(int i=1;i<=pc;i++) { s=0; for(原创 2017-08-08 21:03:54 · 588 阅读 · 0 评论 -
NOIP模板大全
我也不知道为什么会有这种东西??1 数据结构1.1 线段树#include <iostream>#include <cstdio>using namespace std;const int N=1e5;int n,m,tot,root;struct Tree{ int l,r,ls,rs,sum,max,tag;}t[N*2];void push_up(int x){转载 2017-07-20 09:00:58 · 695 阅读 · 0 评论 -
洛谷P3389 【模板】高斯消元法
无解无限解不分开考虑#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespace std;const int inf=0x7fffffff;double Matrix[110][110],ans[100];int N,M,bit=1,used[110];void Kill(i转载 2017-02-18 10:45:52 · 549 阅读 · 0 评论 -
读入优化
直接上代码inline int read()//{ int x=0;char y; while(y<'0'||y>'9') y=getchar();//不是数字时不读入 所以不用考虑空格 while(y>='0'&&y<='9') {y=getchar();x=10*x+y-'0';}//累积 return x;//返回 }a=read();b=read()原创 2017-03-13 16:35:42 · 226 阅读 · 0 评论 -
树链剖分模板题 [HAOI2015]T2
洛谷原题 就是一道树链剖分的模板题 多谢fancy学姐,几乎是照着她改的,但是理解了 难点在2操作 用st[]记录当前节点在线段树上的标号 ed[]记录当前节点的子树上在线段树上的最大标号(这棵树上的节点标号肯定都在一个区间里) 修改时把单点修改和区间修改放一块了 上代码#include<cstdio>#include<vector>#include<iostream>usi原创 2017-03-31 17:18:30 · 351 阅读 · 0 评论 -
矩阵快速幂(以斐波那契数列为例)
小 M 玩数列【问题描述】 小 W 发现了一个神奇的数列: () = ( − 1) + ( − 2) { ≥ 3, (1) = 1, (2) = 1} ,这就是著名的 Fibonacci Sequence = =!。 众所周知,小 M 的数学超级超级好,于是给小 W 出了一道题: 给小 W 两个数 X,Y,其中 X ≤ Y≤ 2^31−1。 小 W 任务就是求出 Fib原创 2017-06-28 18:28:11 · 718 阅读 · 0 评论 -
归并排序求逆序对
某人的讲解 归并排序好懂 求逆序对不好懂qwq 将2段序列合并时,如果后面序列的一个数比前面序列的一个数x小,他必然比第一个序列x后的所有数小,tot+=mid-i+1 (很简单是不是) 裸题#include<iostream>#include<cstdio>using namespace std;int a[1000001],n,q[10000001],l,r,mid,m,i,j,原创 2017-08-01 09:44:33 · 268 阅读 · 0 评论 -
AtCoder Grand Contest 018
A - Getting Difference Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statement There is a box containing N balls. The i-th ball has the integer Ai written on it. Sn原创 2017-07-24 07:47:43 · 334 阅读 · 0 评论 -
数论积累
辗转相除法排列组合翔翔的排列组合原创 2017-07-24 08:11:56 · 233 阅读 · 0 评论 -
SPFA模板
洛谷2951#include<iostream>#include<cstdio>using namespace std;int n,m,d[200001],x,y,edge,head[500001],maxn,biaohao,sum;struct node{int to,cost,nxt;}a[500001];int team[1000001],hed,tail;bool v[50000原创 2017-07-20 07:47:22 · 213 阅读 · 0 评论 -
STL by pcccc
前言 所有常用操作都在代码里 STL可能会很慢,时间允许的话可替代操作还是手写好 建议对每一种都盲敲2~3遍代码,不要眼高手低#include<iostream>#include<cstdio>#include<vector>//!!!头文件using namespace std;vector<int> a[100];int main(){ for(int i=1;i<=2原创 2017-11-02 21:23:18 · 342 阅读 · 0 评论