自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

sepNINE的专栏

As brief as possible

  • 博客(40)
  • 收藏
  • 关注

原创 poj 3787 Convex Hull of Lattice Points 求凸包

题意:裸的凸包。分析:graham模板直接上。代码://poj 3787//sep9#include #include using namespace std;const int maxN=64;struct P{ int x,y; }pnt[maxN],cnt[maxN];int n;int cmp(P a,P b){ if(a.y!=b.y)

2015-03-31 22:45:31 1053

原创 poj 3990 Fermat Point in Quadrangle 凸包和费马点

题意:求一个四边形的费马点。分析:模拟退火要么超时要么wa,这题的数据就是不想让随机算法过的。。其实四边形的费马点很简单,如果是凸四边形的话费马点是对角线交点,如果是凹四边形费马点是凹点。但题目给的四个点顺序是不确定的,所以要先求下凸包。代码://poj 3990//sep9#include #include #include using namespace std;

2015-03-31 19:08:44 800

原创 poj 4048 Chinese Repeating Crossbow 线段规范相交的判断

题意:给n条线段和初始点,求初始点发出的射线最多能穿过多少条线段(有交点就算穿过)。分析:枚举线段端点,判断线段是否规范相交,需要严密的模板。代码://poj 4048//sep9#include using namespace std;typedef long long ll;const ll maxN=2000;const ll maxL=40028;str

2015-03-31 16:14:06 849

原创 poj 4047 Garden 线段树lazy标记与成段更新

线段树lazy标记技术副题详解

2015-03-30 20:29:42 706

原创 poj 4046 Sightseeing 枚举思想在spfa中的应用

题意:给一个图和q个询问,每个询问查询图中两点的(距离+路径上最大值)的最小值。分析:枚举路径上的最大值做spfa,这题丫的卡常数。。。队列用stl的就等着tle吧。代码://poj 4046//sep9#include #define inf ((~(0ULL))>>1)using namespace std;const int maxN=1024;const i

2015-03-29 22:44:17 739

原创 poj 2526 Center of symmetry 哈希查找

题意:给n个不同的点,问是否存在一个点使得这n个点关于它两两对称。分析:首先确定这个对称中心的坐标,然后对每个点哈希查找它的对称点。代码://poj 2526//sep9#include using namespace std;const int maxN=10024;const int hashlen=1000023;const int mod=40013;st

2015-03-29 19:15:58 681

原创 poj 1637 Sightseeing tour 混迹图欧拉回路

题意:求有向边无向边混迹的欧拉回路。分析:对无向边任意重定向,然后转化为网络流问题。代码://poj 1637//sep9#include #include #include using namespace std;const int maxN=256;const int maxM=1024;struct Edge{ int v,f,nxt;}e[max

2015-03-28 23:20:31 653

原创 poj 4045 Power Station dfs求树上最小距离和

题意:给一棵树,每条边的权值为R*I^2,求到所有其他节点权值和最小的点和相应最小权值和。分析:先将图转化成树,然后在树上dfs。代码://poj 4045//sep9#include#includeusing namespace std;const int maxN=50012;vector g[maxN];int vis[maxN],bro[maxN],son

2015-03-27 23:45:56 797

原创 poj 4044 Score Sequence 排序

水题,直接贴代码。代码://poj 4044//sep9#include #include using namespace std;int a[60],b[60];int ans2[60];int n,m;int deal(int index){ int i,j,len=0,t_i,t_j,t_len; for(j=0;j<m;++j) if(b[j]==a[in

2015-03-27 11:50:36 886

原创 poj 4052 Hrinity AC自动机

poj 4052AC自动机精简做法,109行搞定,代码量较平均减少30%。

2015-03-27 10:40:05 1107

原创 poj 1625 Censored! AC自动机+dp+高精度

poj1625 AC自动机+dp+高精度 超繁题,104行搞定,高效简洁不容错过~~~

2015-03-26 18:25:17 792

原创 poj 3208 Apocalypse Someday 自动机+dp

题意:求第n个包含3个连续6的数。分析:设状态0表示末尾没有6,状态1表示末尾有1个6,状态2表示末尾有2个6,状态3表示末尾有3个6或之前有3个6,可构造出确定状态自动机。然后对该自动机进行dp,a[i][j]表示位于自动机的j状态,再走i步,能包括含3个6的数的个数。之后再用数位dp的思想由高位至低位确定最终答案每位上的数。这和AC自动机是有区别的,需好好体会。代码://p

2015-03-25 11:29:55 815

原创 poj 2778 DNA Sequence AC自动机+矩阵幂加速

ac自动机经典题102行代码搞定。

2015-03-24 12:41:52 738

原创 poj 3691 DNA repair AC自动机+dp

poj3691 看了n篇博客总结出的90行简洁ac自动机+dp代码。

2015-03-23 21:59:14 754

原创 poj 3735 Training little cats 矩阵的幂

题意:给一个长度为n的数列,初始化为0,有3种操作:1)将某个元素增加1;2)将某个元素置0;3)交换两个元素。现在给出包含k个操作的一组操作,求m组操作后数列的状态。分析:找出初始矩阵A和转移矩阵T后就可以用快速幂计算了。代码://poj 3735//sep9#include using namespace std;typedef long long LL;cons

2015-03-22 13:05:58 685

原创 poj 3977 Subset 折半枚举

题意:给n(n分析:折半枚举。代码://poj 3977//sep9#include #include using namespace std;typedef long long LL;const int maxN=40;LL a[maxN];LL myabs(LL x){ return x>=0?x:-x;}int main(){ int n;

2015-03-22 10:57:04 1067

原创 poj 3180 The Cow Prom 强连通分量

水题,直接贴代码。//poj 3180//sep9#include #include using namespace std;const int maxN=10024;const int maxM=50048;int sum[maxN];int head[maxN],dfn[maxN],low[maxN],ins[maxN],belong[maxN]; stack s;st

2015-03-21 21:23:31 713

原创 poj 3636 Nested Dolls 动态更新表的二分查找

题意:给n个玩具,每个有属性w,h。如果w1分析:w升序,w相同时h降序排序后是可以贪心的,这里使用了动态维护表的二分算法,表里动态维护了每堆玩具中h的最大值(所以w相同时h要降序)。这题我一开始一看是个拓扑图还想着用什么图算法。。没想到直接可以贪心,不可以有思维定式啊~~代码://poj 3636//sep9#include #include using namesp

2015-03-21 12:44:45 1114

原创 poj 3709 K-Anonymous Sequence dp斜率优化

题意:给长度为n的非严格递增数列a0,a1...an-1,每一次操作可以使数列中的任何一项的值减小1。现在要使数列中每一项都满足其他项中至少有k-1项和它相等。求最少操作次数。分析:dp[i]:=只考虑前i项情况下,满足要求的最小操作次数。s[i]:=a0+a1+...+ai,则dp[i]=min(dp[j]+s[i]-s[j]-aj*(i-j))(0代码://poj 37

2015-03-20 12:23:26 857

原创 poj 3129 How I Wonder What You Are! 点积求两向量夹角

水题,直接贴代码。//poj 3129//sep9#include #include using namespace std;const double eps=0.00000001;struct P{ double x,y,z;}p[512],tel[64];double a[64];int main(){ int i,j,cnt,n,m; while(scanf("

2015-03-19 23:09:48 867

原创 poj 1723 SOLDIERS 中位数

题意:给n个士兵的坐标,要把他们移动到水平且相邻的一行,求最小步数。分析:中位数法,y方向易求,x方向x0->n+i与x0-i->n是对应的,故也可以转换成y方向的情况。代码://poj 1723//sep9#include #include using namespace std;const int maxN=10024;int x[maxN],y[maxN];

2015-03-19 19:50:56 996

原创 poj 1959 Darts 允许重复组合

水题,直接贴代码。//poj 1959//sep9#include using namespace std;int n;int f[128];int solve(){ int x,y,z,sum=0; for(x=0;x<=n&&x<=60;++x) for(y=x;y<=n&&y<=60;++y) for(z=y;z<=n&&z<=60;++z) if(x

2015-03-19 07:39:30 922

原创 poj 3390 Print Words in Lines 动态规划

动态规划原理附题详解。

2015-03-19 00:01:15 1142

原创 poj 2585 Window Pains 暴力枚举排列

题意:在4*4的格子中有9个窗口,窗口会覆盖它之下的窗口,问是否存在一个窗口放置的顺序使得最后的结果与输入相同。分析:在数据规模较小且不需要剪枝的情况下可以暴力(思路清晰代码简单),暴力一般分为枚举子集(for(s=0;s代码://poj 2585//sep9#include #include using namespace std;int order[10];in

2015-03-18 13:10:39 792

原创 poj 1406 Starship Hakodate-maru 暴力枚举

水题,直接贴代码。//poj 1406//sep9# includeusing namespace std;__int64 f1[2024];__int64 f2[3024];int main(){ __int64 index1=0,index2=0,n; for(index1=0;index1<1300;++index1) f1[index1]=index1*index

2015-03-18 06:33:05 976

原创 poj 1628 Deduction 模拟

题意:给一些蕴含式和一个为真的语句集合,求总共能推导出的语句集合。分析:维护一个里面语句都为真的集合就好。ps,这水题居然只有一百多人做出来。。代码://poj 1628//sep9#include #include #include using namespace std;set s1[256],s2[256],s;set::iterator iter;bo

2015-03-17 07:23:14 679

原创 poj 2126 Factoring a Polynomial 数学多项式分解

题意:给一个多项式,求它在实数域内的可分解性。分析:代数基本定理。代码://poj 2126//sep9#include using namespace std;int main(){ int n; scanf("%d",&n); int a,b,c; scanf("%d%d%d",&a,&b,&c); if(n>2) puts("NO"); els

2015-03-16 21:57:36 1082

原创 poj 2135 Farm Tour 最小费用流入门模板

最小费用流90行模板+例题,不容错过!!!

2015-03-16 10:12:08 735

原创 poj 3254 Corn Fields 状态压缩dp

题意:给一块m行n列的土地,有一些格可以种树,另外一些不可以,树不能相邻,问一共有多少种种法。分析:从后往前种,子问题向父问题扩展,当种到某一格时只有他和他后面的n-1个格子的情况对它有影响,故对这n个格子进行编码为状态S,表示种完(多米诺骨牌那题是放置前,注意区别,都可行)这n个格子的状态。父问题由稍小子问题逐步解决,正是动态规划的思想。代码://poj 3254//sep

2015-03-16 07:15:50 743

原创 poj 2688 状态压缩dp解tsp

题意:裸的tsp。分析:用bfs求出任意两点之间的距离后可以暴搜也可以用next_permutation水,但效率肯定不如状压dp。dp[s][u]表示从0出发访问过s集合中的点,目前在点u走过的最短路程。代码://poj 2688//sep9#include #include using namespace std;const int maxW=32;const

2015-03-15 09:35:12 1122

原创 poj 2555 Drink, on Ice 物理坐标计算

题意:把一些冰和一些水混合,求最终的状态和温度。分析:质量守恒+能量守恒。计算时将整条曲线平移至(0,0)开始会比较方便,但是发现当Q=0时T=-30,引入新的横坐标dT=T+30,曲线就从(Q,dT)==(0,0)开始了。代码://poj 2555//sep9#include #include using namespace std;const double cw=

2015-03-14 22:20:58 741

原创 poj 3498 March of the Penguins 点流量有限制的最大流

题意:给n块浮冰的坐标,每块浮冰上的企鹅数和能承受跳起的次数,求有哪些浮冰能让企鹅能到一起。分析:拆点将点流量的限制转化为边流量的限制,求最大流。代码://poj 3498//sep9#include #include #include #include using namespace std;const int maxN=128;const int maxM=

2015-03-14 20:07:51 764

原创 poj 2041 Unreliable Message 字符串处理

水题,直接贴代码。//poj 2041//sep9#include using namespace std;char mode[128];char ori[128],res[128];int len;void J(){ ori[0]=res[len-1]; for(int i=1;i<len;++i) ori[i]=res[i-1];}void C(){ or

2015-03-14 08:18:34 1062

原创 poj 2396 Budget 边容量有上下界的最大流

题意:给一个矩阵的每行和及每列和,在给一些行列或点的限制条件,求一个满足的矩阵。分析:转化为有上下界的网络流,注意等于也是一种上下界关系,然后用dinic算法。代码://poj 2396//sep9#include #include #include using namespace std;const int maxN=210;const int maxM=40;

2015-03-14 00:05:08 1192

原创 poj 2967 Triangles 排序

题意:给n跟木棒,问他们是否满足1.其中3根能组成三角形,2.不是任意3根都能组成三角形。分析:对于ac,对整个数组排序后判断即可。这题用c++提交会超时,要用g++。代码://poj 2967//sep9#include #include #include using namespace std;int a[1000024]; int n;char ch;

2015-03-10 13:40:45 1071

原创 poj 2918 Tudoku 数独dfs

题意:解数独游戏。分析:这道数独的数独直接dfs就能过。代码://poj 2918//sep9#includeusing namespace std;char s[12][12];int board[12][12];int CheckSquare[12][12];int CheckRow[12][12];int CheckColumn[12][12];int

2015-03-09 20:34:46 913

原创 poj 3714 Raid 分治法求平面最近点对

题意:给平面上的n个点,求两点间的最短距离。分析:分治法,保存点用vector会tle...代码://poj 3714//sep9#include #include #include using namespace std;const double INF=1e50;struct P{ double x,y; int type;}p[240000],b[2

2015-03-09 19:01:34 1364

原创 poj 2230 Watchcow 欧拉回路

题意:给一个图,求一种从点1出发,经过所有边恰好两次回到点1的方案,数据保证有解。分析:欧拉回路,改下次数就好了。代码://poj 2230//sep9#include #include #include using namespace std;const int maxN=10024;const int maxM=50048;int head[maxN];i

2015-03-09 01:02:37 635

原创 poj 1220 NUMBER BASE CONVERSION 高精度进制转换

题意:实现一个高精度数的进制转换。分析:discuss里找到的精妙简洁模板。代码:#include using namespace std;const int maxN=600;char ori[maxN],ans[maxN];int t[maxN],A[maxN];int main(){ int cases,a,b; scanf("%d",&cases);

2015-03-06 01:55:02 875

原创 poj 2311 Cutting Game nim与状态的grundy值

博弈论中grundy值的例题

2015-03-06 00:09:27 790

空空如也

空空如也

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

TA关注的人

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