自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

stormdpzh的专栏

路漫漫其修远兮,吾将上下而求索

  • 博客(25)
  • 资源 (1)
  • 收藏
  • 关注

原创 poj 3616 Milking Time

dp题。 /* POJ: 3616 Milking Time */ #include #include #include #include #include #define M 1005 using namespace std; struct Interval { long long start, end; long long eff; bool

2012-03-25 18:59:29 723

原创 poj 3615 Cow Hurdles

赤裸裸的floyd,思路很直接。很容易想到。 /* POJ: 3615 Cow Hurdles */ #include #include #include #include #include #define MaxN 305 #define MaxD (1 << 20) using namespace std; long map[MaxN][MaxN]; int

2012-03-25 18:51:29 584

原创 poj 3614 Sunscreen

贪心。 /* Poj: 3614 Sunscreen */ #include #include #include #include #include #define MaxLC 2505 using namespace std; struct Cow { int minn, maxx; bool operator < (const struct Cow

2012-03-25 18:45:46 941

原创 poj 3620 Avoid The Lakes

很简单的dfs /* Poj: 3620 Avoid The Lakes */ #include #include #include #include #include #define MaxN 105 using namespace std; int dirx[4] = {0, 0, -1, 1}; int diry[4] = {-1, 1, 0, 0}; bool map[M

2012-03-25 18:42:00 580

原创 poj 1936 All in All

刚做了三个字符串的题都1a了,这个算是最简单的了。 总体来说,以前很怕怕字符串的题,现在也是,路漫漫啊!自己的水平还只能处理数据范围不大或者比较常规的题目。 /* POJ: 1936 All in All */ #include #include #include #include using namespace std; string s, t; int main() {

2012-03-24 21:16:27 629

原创 poj 3080 Blue Jeans

c++的stl等东西在很多时候的确比C语言方便,减少代码又提高效率。 /* Poj: 3080 Blue Jeans */ #include #include #include #include #define StrLen 60 using namespace std; string str[11]; int n; int main() { //freopen("d

2012-03-24 20:55:17 1024 2

原创 poj 1035 Spell checker

很简单的1a了,代码也很好写。思路也很简单,直接暴力就是了,数据很弱因为。没有任何优化,391ms。 /* POJ: 1035 Spell checker */ #include #include #include #include #include #include #include using namespace std; vector vec; vector res;

2012-03-24 19:57:54 667

原创 Fuzhou 2011 Xiangqi

今天跟人做这个,超级模拟,wa了七次…… #include #include #include using namespace std; const int ch_x[4] = {-1, 0, 1, 0}; const int ch_y[4] = {0, 1, 0, -1}; const int ho_x[8] = {-2, -2, -1, 1, 2, 2, 1, -1}; con

2012-03-24 18:53:03 569

原创 usaco runround

一个纯粹的模拟题。 /* ID: stormdp1 LANG: C++ TASK: runround */ #include #include #include using namespace std; bool judge[10]; int digit[20]; long long n; int len; bool isOk() { memset(judge, false,

2012-03-22 15:33:38 478

原创 usaco preface

题目很简单,这种题做起来也不会错,不过做法很搓,代码很长。 /* ID: stormdp1 LANG: C++ TASK: preface */ #include #include #include using namespace std; int i, v, x; int l, c, d; int m; void Cal(int n) { if(n / 1000 > 0)

2012-03-21 23:08:05 433

原创 hdoj 1151 Air Raid

又一个二分图最大匹配问题。匈牙利算法总是很好写的,就是有时候求的不是匹配数,比如最大独立集等。 做了七八个图论的题,其他都交了一次,只有这个交了两次才过,原因是没注意intersection的编号是从1开始,还按照0算了,于是贡献一次wa! 最近做了好几个这种题,直接贴代码: /* Hdoj: 1151 Air Raid */ #include #include #include #

2012-03-21 17:56:54 932

原创 hdoj 1068 Girls and Boys

匈牙利算法求最大匹配,不过用顶点数减去最大匹配数才是最大独立集数。 /* Hdoj: 1068 Girls and Boys */ #include #include #include #define MaxS 1005 using namespace std; bool map[MaxS][MaxS]; bool checked[MaxS]; int xM[MaxS], yM[Ma

2012-03-20 22:15:37 625

原创 hdoj 1054 Strategic Game

动态规划+深搜 /* HDOJ: 1054 Strategic Game */ #include #include #include #define MaxN 1505 using namespace std; struct Node { int no; int sons; int son_no[MaxN]; bool isRoot; }node[

2012-03-20 21:15:07 967

原创 hdoj 1301 Jungle Roads

很好写的一个prim。 一个小技巧:输入这样的字符主句时最好使用c++中的cin,cin会自动过滤掉空格,而scanf不会,当然些习惯了用scanf或getchar也无所谓,毕竟scanf输入大数据比cin快。本人在很久以前用cin超时用scanf过了一个题之后习惯也是输入用scanf,不过遇到字符就cin。 /* Hdoj: 1301 Jungle Roads */ #include #i

2012-03-20 20:15:32 848

原创 hdoj1162 Eddy's picture

不知道杭电上什么时候能出题的时候把英语水平提高一下~ prim,直接贴代码: /* Hdoj: 1162 Eddy's picture */ #include #include #include #include #define MaxPoint 105 #define MaxDis 10000000.0 using namespace std; struct Point {

2012-03-20 19:11:27 597

原创 hdoj 1142 A Walk Through the Forest

找到所有2到1的最短路的距离,然后从1开始搜索符合条件的最短路。 /* HDOJ: 1142 A Walk Through the Forest */ #include #include #include #define MaxD (1 << 20) #define MaxN (1 << 10) using namespace std; long map[MaxN][MaxN];

2012-03-18 19:23:46 1339

原创 poj 3041 Asteroids

匈牙利算法求最大匹配。 把x和y看作两个集合,如果 (x, y)有一个asteroid,就在x和y之间连一条边,这样就有了一个二分图。 这里因为不需要求出具体的匹配,所以只需不断寻找交错链(也就是增广路、交错轨),每找到一条,结果加1(因为找到一条交错链意味着匹配数+1) 代码: /* Poj: 3041 Asteroids */ #include #include #includ

2012-03-18 14:42:17 661

原创 poj 1258 Agri-Net

Prim算法求最小生成树。 #include #define MaxN 105 #define INF 100005 long a[MaxN][MaxN]; long Prim(int n); int main() { int N; int i, j; //freopen("data.in", "rb", stdin); while(scanf("%d", &

2012-03-18 13:57:11 731

原创 poj 2485 Highways

今天在做图论的题目。感觉图论的题目要不就不会做,要会做比较容易1a,因为坑人的地方比较少。 /* POJ: 2485 Highways */ #include #include #include #define MaxV 505 #define MaxL (1 << 20) using namespace std; long length[MaxV][MaxV]; int n; in

2012-03-18 13:42:24 495

原创 poj 1789 Truck History

wa了一次,因为把结果输出时没有输出 ".",很活该。prim算法求最小生成树,不过不需要保存边,只需要把最小的分母几下就是了。 代码如下: /* Poj: 1789 Truck History */ #include #include #include #define MaxDiff 1000 #define MaxP 2005 using namespace std; char

2012-03-18 13:02:43 655

原创 poj 2240 Arbitrage

最近做题总是错,要改几次才过。这是很难得的一个1a了。 bellman算法,和之前做过的1860类似,一个类型。 /* POJ: 2240 Arbitrage */ #include #include #include #include #include using namespace std; const int M = 40; map search_map; double

2012-03-18 11:58:34 663

原创 poj 1125 Stockbroker Grapevine

Floyd算法。0ms水过。 代码如下: /* Poj: Stockbroker Grapevine */ #include #include #include #include #define MAX_TIME (1 << 20) #define MIN(a, b) ((a) > (b) ? (b) : (a)) using namespace std; const int

2012-03-17 21:16:17 382

原创 Poj 3259 Wormholes

Bellman算法。进行n-1次循环之后如果还能继续修改使dis减小,说明存在可以使时间变小的回路。 /* Poj: 3259: Wormholes */ #include #include #include #define Max 32767 using namespace std; const int M = 2705; const int N = 505; struct

2012-03-16 17:41:27 550

原创 usaco: Sorting a Three-Valued Sequence

把原序列按 non-decreasing排序,然后把排序后的数组和原序列一一比较,找出本该排1的位置放了2的、3的,本该放2的位置放了1的、3的…… 由于一次exchange可以把1和2对换,1和3对换,2和3对换,所以做这些交换,然后剩下的就是三个都不同的了,这样每一组都至少经过两次交换才能恢复(比如312经两次交换才可以变成123)。看代码更清楚,很简单的思路,很简短的代码。

2012-03-14 21:48:33 566

原创 Poj1953 WorldCupNoise

斐波拉契数列。 简单说明:输入1时,结果有两种:0,1;输入2时,结果有00,01,10,输入三时,结果有000,001,010,100,101……无论输入几,总结过数都是最后一位为0的数字个数加上最后一位为1的数字个数,而当前一位要产生1,前一位最后只能是0,当前一位要产生0,前一位最后可以为1,也可以为0。 设O[i]、Z[i]分别表示i位数的最后一位为0的数和最后一位为1的数,f

2012-03-14 21:42:19 569

poj题目代码

poj上一些题目的代码。都是自己平时做的一些题。拿出来用于交流。这些代码见证了从最初只会写a+b到半年前的一个过程。

2013-03-12

空空如也

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

TA关注的人

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