自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(29)
  • 资源 (1)
  • 收藏
  • 关注

原创 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 290

原创 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 201

原创 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 222

原创 bitset

//http://blog.csdn.net/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 418

原创 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 315

原创 spfa+位运算 2017.10.9 t3

#include<iostream>#include<cstdio>#include<queue>#define Maxn (1<<20)+200005#define Maxm 400001using namespace std;int n,m,to[Maxn],nxt[Maxn],head[Maxn],e,val[Maxn],a[Maxm],x,y,dis[Maxn];bool us

2017-10-10 08:25:30 178

原创 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 254

原创 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 836

原创 (方法)枚举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 540

原创 线段树

贾比奇的博客带lazytag的线段树模板/*第一行包含两个整数N、M,分别表示该数列数字的个数和操作的总个数。第二行包含N个用空格分隔的整数,其中第i个数字表示数列第i项的初始值。接下来M行每行包含3或4个整数,表示一个操作,具体如下:操作1: 格式:1 x y k 含义:将区间[x,y]内每个数加上k操作2: 格式:2 x y 含义:输出区间[x,y]内每个数的和*/#include

2017-08-04 11:18:00 236

原创 排列组合

小比琪的屁屁 排列 组合 排列有顺序,组合没顺序;就是这么简单!!公式 很好理解的 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 444

原创 归并排序求逆序对

某人的讲解 归并排序好懂 求逆序对不好懂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 233

原创 蒜头君的树

蒜头君的树题解 先存图,再dfs,dfs的过程中统计以x点为子树的点的总数cnt[x],这样可以求出来x和fa[x]连的这条边一共被使用了(n-cnt[x])*cnt[x]次 再求出来最短路之和tot(因为是树,所以最短路好求),对于每次修改,只需要将将差乘上使用次数就好了#include<iostream>#include<cstdio>using namespace std;l

2017-07-31 17:29:07 525

原创 强连通分量

讲解一道模板题牛的舞会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 281

原创 DP动态规划(持续更新)

最长不下降子序列 不用我说了吧 有一个O(nlogn)的做法 最长公共子序列 smartoj1212#include<stdio.h>using namespace std;char a[30001],b[30001];int dp[3001][3001];int main(){ scanf("%s",a+1);scanf("%s",b+1); for(

2017-07-26 09:07:47 248

原创 数论积累

辗转相除法排列组合翔翔的排列组合

2017-07-24 08:11:56 184

原创 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 276

转载 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 597

原创 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 173

原创 矩阵快速幂(以斐波那契数列为例)

小 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 659

原创 树链剖分模板题 [HAOI2015]T2

洛谷原题 就是一道树链剖分的模板题 多谢fancy学姐,几乎是照着她改的,但是理解了 难点在2操作 用st[]记录当前节点在线段树上的标号 ed[]记录当前节点的子树上在线段树上的最大标号(这棵树上的节点标号肯定都在一个区间里) 修改时把单点修改和区间修改放一块了 上代码#include<cstdio>#include<vector>#include<iostream>usi

2017-03-31 17:18:30 288

原创 二分答案

while(l<=r) { mid=(l+r)/2; if(ans>=mid) num=mid,l=mid+1;//r和l位置不能变 else r=mid-1; }

2017-03-17 20:46:45 417

原创 Dijkstra算法

这是转的Dijkstra算法想法(部分转)a.初始时,S只包含源点,即S={v},v的距离为0。U包含除v外的其他顶磅点,即:U={其余顶点},若v与U中顶点u有边,则(u,v)正常有权值,若u不是v的出边邻接点,则(u,v)权值为∞。 b.从U中选取一个距离v最小的顶点k,把k,加入S中(该选定的距离就是v到k的最短路径长度)。 c.以k为新考虑的中间点,修改U中各顶点的距离;若从源点v到顶点

2017-03-17 11:29:08 319

原创 读入优化

直接上代码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 190

转载 为了和谐

为了和谐(square.pas/c/cpp)[ 问题背景]在机房里,有两只小可爱,一只大可爱,一只小可爱。其中大可 爱对大的东西感兴趣,小可爱对小的东西感兴趣。 现在有一个 a*b 的矩阵,矩阵中每个位置都有一个非负整数 i (0<=i<=2000 000 000),两只小可爱要在这个矩阵中选择一个 n*n 的 正方形,大可爱要正方形中的最大数,小可爱要正方形中的最小数。 但是,如果两个人

2017-03-08 21:20:24 247

原创 扩展欧几里得

我写的太辣鸡啦qwq 看看大神Orz扩展欧几里得的几个重要定理如果d = gcd(a, b),则必能找到正的或负的整数k和l,使d = a*k + b*l。这是判断方程是否有整数解的啦若gcd(a, b) = d,则方程ax ≡ c (mod b)在[0, b/d - 1]上有唯一解。 若gcd(a, b) = 1,则方程ax ≡ c (mod b)在[0, b-1]上有唯一解。 不用证啦

2017-02-20 17:15:18 262

转载 洛谷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 489

转载 求有向图的强连通分量(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 348

原创 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 227

动态规划专题

动态规划专题

2017-07-25

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除