上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 31 下一页
摘要: /* 找出能连通所有点的一棵树 是的最大的边最小 很显然就是最小生成树. 堆优化prim. */ #include #include #include #include #include #define maxn 1010 #define inf 999999999 using namespace std; int n,m,num,head[maxn],ans,tot; bool f[ma... 阅读全文
posted @ 2016-07-29 21:28 一入OI深似海 阅读(220) 评论(0) 推荐(0) 编辑
摘要: /* 这做法好像有个很高大上的名字叫做分层图. 其实就是按照题目的意思重新建图 节点有n个变成n*k个 每个表示节点的编号和剩下能用的k值 然后...卡spfa 需要堆优化的dij */ #include #include #include #include #include #define pa pair #define mk make_pair #define maxn 2000010 ... 阅读全文
posted @ 2016-07-29 19:58 一入OI深似海 阅读(176) 评论(0) 推荐(0) 编辑
摘要: /* 分三种情况 1 有环:找环长的gcd作为max gcd的超过2的最小因子作为min 2 树:所有最长链的和作为max 3为min (最长链≥3) 3 两条相交链:找出所有的这样的两条链的差 同1求 显然第三种不好处理 看了别人的做法是+反向-1的边 1 3就能合并了. */ #include #include #include #include #define maxn 1000010 ... 阅读全文
posted @ 2016-07-29 19:52 一入OI深似海 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 感受一下不同做法的时间 1.map+单向bfs 125ms #include #include #include #include #include using namespace std; string st,aim=" 123804765",s,si; char x; mapp; queueq; queuet; int main() { cin>>st; st=' '+st;... 阅读全文
posted @ 2016-07-29 09:41 一入OI深似海 阅读(545) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #define maxn 30010 using namespace std; int m,fa[maxn],top[maxn],num[maxn]; char s; int find(int x) { if(x==fa[x])return x; int f=fa[x]; fa[x]=find(fa[x]); ... 阅读全文
posted @ 2016-07-26 20:56 一入OI深似海 阅读(157) 评论(0) 推荐(0) 编辑
摘要: /* n*m个点中选3个 再排除三点共线 共线分两类 1 在横线或者竖线上 m*C(n,3) n*C(m,3) 2 在对角线上 这个比较麻烦 以为对角线和矩阵是一一对应的 我们转化成求矩阵 并且保证有两个点在矩阵的角上 接下来的问题就是求 n m 大小的矩阵对角线经过几个点 我们设可构成的最小的三角形的底和高分别是ni mi 显然ni mi 分别是n m的约数 那么分成的线段数也是... 阅读全文
posted @ 2016-07-26 20:53 一入OI深似海 阅读(266) 评论(0) 推荐(1) 编辑
摘要: /*先贴个n*n的*/ #include #include #include #define maxn 1000010 using namespace std; int n,k,h[maxn],f[maxn],Q; int main() { scanf("%d",&n); for(int i=1;i=h[j])f[i]=min(f[i],f[j]+1); ... 阅读全文
posted @ 2016-07-25 19:21 一入OI深似海 阅读(146) 评论(0) 推荐(0) 编辑
摘要: /* 开始以为是二分...后来发现丫不单调... */ #include #include #include #define maxn 1000010 using namespace std; int n,l,r,ans,tmin[maxn],tmax[maxn],a[maxn]; int qmin[maxn],qmax[maxn],headmin,tailmin,headmax,tailma... 阅读全文
posted @ 2016-07-25 19:19 一入OI深似海 阅读(216) 评论(0) 推荐(0) 编辑
摘要: /* 裸地单调队列.. 第一次写 写的好丑.... */ #include #include #include #define maxn 1000010 using namespace std; int n,k,x,a[maxn],t[maxn],q[maxn],head=1,tail; int init() { int f=1,x=0;char s=getchar(); wh... 阅读全文
posted @ 2016-07-25 10:29 一入OI深似海 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 1.对于一个整数数组,要求资持单点修改,查询区间l r中的max(ai-aj)(l<=j<i<=r) 阅读全文
posted @ 2016-07-18 20:48 一入OI深似海 阅读(175) 评论(0) 推荐(0) 编辑
上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 31 下一页