自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 poj 3648 Wedding 2sat

2sat #include #include #include using namespace std; const int maxn=30*2+9; int n,m; int head[maxn]; int lon; int dfn[maxn],low[maxn],stack[maxn],instack[maxn],s[maxn],un[maxn]; int count,top,con;

2013-05-22 20:26:03 636

原创 poj 2723 Get Luffy Out 2sat

二分+2sat判可行性#include #include #include using namespace std; const int maxn=1024*2+9; int doorx[1<<12],doory[1<<12],x[maxn],y[maxn]; int n,m; int dfn[maxn<<1],low[maxn<<1],stack[maxn<<1],instack[maxn

2013-05-21 22:46:38 663

原创 poj 3683 Priest John's Busiest Day 2-sat

经典2-sat问题,需要输出解 #include #include #include using namespace std; const int maxn=2e3+9; int head[4][maxn],lon; int dfn[maxn],low[maxn],s[maxn],stack[maxn],instack[maxn]; int que[maxn],in[maxn],to[

2013-05-21 13:33:32 838

原创 poj 2553 tarjan

求一个图出度为0的强连通分量。 #include #include #include const int maxn=5500; using namespace std; struct { int to,next; }e[maxn*maxn]; int head[maxn],lon; void edgeini() { memset(head,-1,sizeof(head));

2013-05-19 21:57:17 668

原创 poj 3177 Redundant Paths tarjan

在一个无向图中要增加几条边才能使得整个图成为双连通,对tarjan算法进行更改,求得去掉割边都的叶子节点的个数,这个数目要是为1,ans=0.否则,ans=(n+1)/2.#include #include #include using namespace std; const int maxn=5e3+9; struct { int to,next; }e[maxn<<2]; in

2013-05-19 21:50:39 736

原创 poj 3020 Antenna Placement 二分图匹配

黑白染色  然后求二分图最大匹配#include #include #include using namespace std; const int maxn=40+9; int n,m; char a[maxn][maxn]; struct { int to,next; }e[maxn*10*4]; int head[maxn*10],lon; void edgeini() {

2013-05-18 16:00:50 740

原创 poj 1523 spf 求割点

无向图求割点的模版题。就是对tarjan的运用。 #include #include #include using namespace std; const int maxn=1e3+9,N=1e3; bool e[maxn][maxn]; int dfn[maxn],low[maxn],count,in[maxn]; void tarjan(int t,int from) {

2013-05-16 15:14:20 751

原创 poj 1470 Closest Common Ancestors

最近公共祖先的题目。第一个点不一定是跟。 #include #include #include using namespace std; const int maxn=900+9; int head[maxn],lon,qhead[maxn],qlon; int ans[maxn],chk[maxn],f[maxn],in[maxn]; struct node {

2013-05-08 21:20:38 721

原创 poj 3378 Crazy Thairs dp

用树状数组优化转移复杂度,结果会超long long,要用高精度。#include #include #include #include typedef unsigned long long ll; using namespace std; const int maxn=5e4+9; ll tree[6][maxn],dp[maxn][6]; int a[maxn]; int n; ty

2013-05-04 02:18:06 1013

原创 poj 3017 Cut the Sequence dp

dp[k]是非递增的,然后对于同样的转移代价,我们只需要找到i最小的dp[i]及可。  所以可以用单调队列维护一个递减的序列,存储转移代价,即一段中的最大值。对于每个转移代价下的dp[i]+a[j],把它压入set中。每次找到最小的值来更新dp[k]。         维护队列,set,有比较麻烦的边界条件,要好好处理。 #include #include #include #

2013-05-03 18:03:50 788

poj 3947 题解

经典O(n)求最长回文 acmer新手可看

2013-09-24

空空如也

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

TA关注的人

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