2012年8月3日

nyoj 36 经典DP之最长公共子序列

摘要: 最长公共子序列时间限制:3000 ms | 内存限制:65535 KB难度:3描述咱们就不拐弯抹角了,如题,需要你做的就是写一个程序,得出最长公共子序列。tip:最长公共子序列也称作最长公共子串(不要求连续),英文缩写为LCS(Longest Common Subsequence)。其定义是,一个序列 S ,如果分别是两个或多个已知序列的子序列,且是所有符合此条件序列中最长的,则 S 称为已知序列的最长公共子序列。输入第一行给出一个整数N(0<N<100)表示待测数据组数接下来每组数据两行,分别为待测的两组字符串。每个字符串长度不大于1000.输出每组测试数据输出一个整数,表示最长 阅读全文

posted @ 2012-08-03 20:04 不悔梦归处 阅读(1125) 评论(0) 推荐(0) 编辑

2012年7月26日

nyoj 284 poj 2312 搜索之水池数目

摘要: 水池数目时间限制:3000 ms | 内存限制:65535 KB难度:4描述南阳理工学院校园里有一些小河和一些湖泊,现在,我们把它们通一看成水池,假设有一张我们学校的某处的地图,这个地图上仅标识了此处是否是水池,现在,你的任务来了,请用计算机算出该地图中共有几个水池。输入第一行输入一个整数N,表示共有N组测试数据每一组数据都是先输入该地图的行数m(0<m<100)与列数n(0<n<100),然后,输入接下来的m行每行输入n个数,表示此处有水还是没水(1表示此处是水池,0表示此处是地面)输出输出该地图中水池的个数。要注意,每个水池的旁边(上下左右四个位置)如果还是水池的话 阅读全文

posted @ 2012-07-26 11:29 不悔梦归处 阅读(301) 评论(0) 推荐(0) 编辑

2012年7月25日

nyoj 284 poj 2312 搜索之坦克大战

摘要: 坦克大战时间限制:1000 ms | 内存限制:65535 KB难度:3描述Many of us had played the game "Battle city" in our childhood, and some people (like me) even often play it on computer now. What we are discussing is a simple edition of this game. Given a map that consists of empty spaces, rivers, steel walls and bri 阅读全文

posted @ 2012-07-25 20:27 不悔梦归处 阅读(393) 评论(1) 推荐(0) 编辑

2012年7月19日

hdoj 4256 The Famous Clock

摘要: The Famous ClockTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 217Accepted Submission(s): 179Problem DescriptionMr. B, Mr. G and Mr. M are now in Warsaw, Poland, for the 2012’s ACM-ICPC World Finals Contest. They’ve decided to take a 5 hours train 阅读全文

posted @ 2012-07-19 09:20 不悔梦归处 阅读(279) 评论(0) 推荐(0) 编辑

hdoj 4255 A Famous Grid (素数打表+bfs)

摘要: A Famous GridTime Limit: 10000/3000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 365Accepted Submission(s): 148Problem DescriptionMr. B has recently discovered the grid named "spiral grid".Construct the grid like the following figure. (The grid is actually 阅读全文

posted @ 2012-07-19 09:18 不悔梦归处 阅读(413) 评论(0) 推荐(0) 编辑

hdoj 4252 A Famous City

摘要: A Famous CityTime Limit: 10000/3000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 372Accepted Submission(s): 162Problem DescriptionAfter Mr. B arrived in Warsaw, he was shocked by the skyscrapers and took several photos. But now when he looks at these photos, he finds 阅读全文

posted @ 2012-07-19 09:12 不悔梦归处 阅读(228) 评论(0) 推荐(0) 编辑

hdoj 4251 The Famous ICPC Team Again

摘要: The Famous ICPC Team AgainTime Limit: 30000/15000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 203Accepted Submission(s): 91Problem DescriptionWhen Mr. B, Mr. G and Mr. M were preparing for the 2012 ACM-ICPC World Final Contest, Mr. B had collected a large set of con 阅读全文

posted @ 2012-07-19 09:04 不悔梦归处 阅读(254) 评论(0) 推荐(0) 编辑

hdoj 4245 水题之A Famous Music Composer

摘要: A Famous Music ComposerTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 216Accepted Submission(s): 129Problem DescriptionMr. B is a famous music composer. One of his most famous work was his set of preludes. These 24 pieces span the 24 musical keys 阅读全文

posted @ 2012-07-19 08:58 不悔梦归处 阅读(1029) 评论(0) 推荐(1) 编辑

hdoj 1532最大流之Drainage Ditches

摘要: Drainage DitchesTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4149Accepted Submission(s): 1929Problem DescriptionEvery time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means that the clover is 阅读全文

posted @ 2012-07-19 08:52 不悔梦归处 阅读(595) 评论(3) 推荐(0) 编辑

2012年7月16日

hdoj 1879 最小生成树之继续畅通工程

摘要: 继续畅通工程Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7131Accepted Submission(s): 3003Problem Description省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。现得到城镇道路统计表,表中列出了任意两城镇间修建道路的费用,以及该道路是否已经修通的状态。现请你编写程序,计算出全省畅通需要的最低成本。Input测试输入包含若干测 阅读全文

posted @ 2012-07-16 10:51 不悔梦归处 阅读(161) 评论(0) 推荐(0) 编辑

hdoj1875 最小生成树之畅通工程再续

摘要: 畅通工程再续Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6695Accepted Submission(s): 2000Problem Description相信大家都听说一个“百岛湖”的地方吧,百岛湖的居民生活在不同的小岛中,当他们想去其他的小岛时都要通过划小船来实现。现在政府决定大力发展百岛湖,发展首先要解决的问题当然是交通问题,政府决定实现百岛湖的全畅通!经过考察小组RPRush对百岛湖的情况充分了解后,决定在符合条件的小岛间建上桥, 阅读全文

posted @ 2012-07-16 10:46 不悔梦归处 阅读(198) 评论(0) 推荐(0) 编辑

hdoj 1863 最小生成树之畅通工程

摘要: 畅通工程Time Limit: 1000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9311Accepted Submission(s): 3617Problem Description省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。Input测试输入包含若干测试用例。每个测试用例的第1 阅读全文

posted @ 2012-07-16 10:42 不悔梦归处 阅读(165) 评论(0) 推荐(0) 编辑

2012年7月12日

hdoj 1874最短路之最短路径问题

摘要: 最短路径问题Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4103Accepted Submission(s): 1220Problem Description给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的。Input输入n,m,点的编号是1~n,然后是m行,每行4个数 a,b,d,p,表示a和b之间有一条边,且其长度为d,花费为p。最后一行是 阅读全文

posted @ 2012-07-12 21:54 不悔梦归处 阅读(147) 评论(0) 推荐(0) 编辑

hdoj 1874最短路之畅通工程续

摘要: 畅通工程续Time Limit: 3000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11676Accepted Submission(s): 3921Problem Description某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。Input本题目包含多 阅读全文

posted @ 2012-07-12 17:07 不悔梦归处 阅读(1826) 评论(0) 推荐(0) 编辑

并查集之 A Walk Through the Forest

摘要: A Walk Through the ForestTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3047Accepted Submission(s): 1114Problem DescriptionJimmy experiences a lot of stress at work these days, especially since his accident made working difficult. To relax after a 阅读全文

posted @ 2012-07-12 14:58 不悔梦归处 阅读(374) 评论(0) 推荐(0) 编辑

并查集之 How Many Tables

摘要: How Many TablesTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5718Accepted Submission(s): 2690Problem DescriptionToday is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to know how many tables he need 阅读全文

posted @ 2012-07-12 14:53 不悔梦归处 阅读(142) 评论(0) 推荐(0) 编辑

并查集之 Is It A Tree?

摘要: Is It A Tree?Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6600Accepted Submission(s): 1545Problem DescriptionA tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed 阅读全文

posted @ 2012-07-12 14:46 不悔梦归处 阅读(724) 评论(0) 推荐(1) 编辑

2012年7月11日

并查集之Dragon Balls

摘要: Dragon Ballshttp://acm.hdu.edu.cn/showproblem.php?pid=3635题意:给出n个龙珠,开始的时候第i个龙珠在第i个城市,然后下面有q个操作 T a b:把第a个龙珠所在城市的所有龙珠移动到第b个龙珠所在的城市 Q a :询问第a个龙珠所在的城市,这个城市有多少颗龙珠,这颗龙珠被移动多少次思路:第a个龙珠所在的城市与这个城市有多少颗龙珠比较简单用并查集找到结点a的根结点与根结点的秩就行了,而龙珠a被移动的次数比较麻烦,我们讲合并两个集合的过程看做第一个集合的根结点移动次数+1,那对于任意一个结点就可以用cnt[a]+cnt[find(a)]表示a 阅读全文

posted @ 2012-07-11 20:00 不悔梦归处 阅读(249) 评论(0) 推荐(0) 编辑

并查集之 Play on Words

摘要: Play on WordsTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2589Accepted Submission(s): 830Problem DescriptionSome of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because 阅读全文

posted @ 2012-07-11 09:59 不悔梦归处 阅读(206) 评论(0) 推荐(0) 编辑

2012年7月10日

并查集之食物链

摘要: 食物链Time Limit: 1000MSMemory Limit: 10000KTotal Submissions: 29339Accepted: 8561Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说法是"2 X Y",表示X吃Y。 此人对N个动物,用上述两种说法,一句接一句地 阅读全文

posted @ 2012-07-10 19:51 不悔梦归处 阅读(350) 评论(0) 推荐(0) 编辑

并查集之畅通工程

摘要: 畅通工程Time Limit: 4000/2000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 15836Accepted Submission(s): 8136Problem Description某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input测试输入包含若干测试用例。每个测试用例的第1行给 阅读全文

posted @ 2012-07-10 19:47 不悔梦归处 阅读(208) 评论(0) 推荐(0) 编辑

并查集之小希的迷宫

摘要: 小希的迷宫Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12513Accepted Submission(s): 3717题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1272Problem Description上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果 阅读全文

posted @ 2012-07-10 16:19 不悔梦归处 阅读(231) 评论(0) 推荐(0) 编辑

2012年7月8日

阶乘之和

摘要: 阶乘之和题目连接 http://acm.nyist.net/JudgeOnline/problem.php?pid=91时间限制:3000 ms | 内存限制:65535 KB难度:3描述给你一个非负数整数n,判断n是不是一些数(这些数不允许重复使用,且为正数)的阶乘之和,如9=1!+2!+3!,如果是,则输出Yes,否则输出No;输入第一行有一个整数0<m<100,表示有m组测试数据;每组测试数据有一个正整数n<1000000;输出如果符合条件,输出Yes,否则输出No;样例输入2910样例输出YesNoView Code 1 #include <iostream&g 阅读全文

posted @ 2012-07-08 21:11 不悔梦归处 阅读(206) 评论(0) 推荐(0) 编辑

背包问题

摘要: 背包问题题目连接 http://acm.nyist.net/JudgeOnline/problem.php?pid=106时间限制:3000 ms | 内存限制:65535 KB难度:3描述现在有很多物品(它们是可以分割的),我们知道它们每个物品的单位重量的价值v和重量w(1<=v,w<=10);如果给你一个背包它能容纳的重量为m(10<=m<=20),你所要做的就是把物品装到背包里,使背包里的物品的价值总和最大。输入第一行输入一个正整数n(1<=n<=5),表示有n组测试数据;随后有n测试数据,每组测试数据的第一行有两个正整数s,m(1<=s< 阅读全文

posted @ 2012-07-08 21:06 不悔梦归处 阅读(169) 评论(0) 推荐(0) 编辑

2012年5月12日

Area of a Parallelogram

摘要: http://acm.hust.edu.cn:8080/judge/contest/view.action?cid=8086#problem/HDescriptionA parallelogram is a quadrilateral with two pairs of parallel sides. See the picture below:Fig: a parallelogramNow you are given the co ordinates of A, B and C, you have to find the coordinates of D and the area of th 阅读全文

posted @ 2012-05-12 15:33 不悔梦归处 阅读(370) 评论(0) 推荐(0) 编辑

Harmonic Number

摘要: http://acm.hust.edu.cn:8080/judge/contest/view.action?cid=8086#problem/DD - Harmonic NumberDescriptionIn mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers:In this problem, you are given n, you have to find Hn.InputInput starts with an integer T (≤ 1000 阅读全文

posted @ 2012-05-12 15:30 不悔梦归处 阅读(770) 评论(0) 推荐(0) 编辑

False Ordering

摘要: http://acm.hust.edu.cn:8080/judge/contest/view.action?cid=8086#problem/AA - False OrderingDescriptionWe define b is a Divisor of a number a if a is divisible by b. So, the divisors of 12 are 1, 2, 3, 4, 6, 12. So, 12 has 6 divisors.Now you have to order all the integers from 1 to 1000. x will come b 阅读全文

posted @ 2012-05-12 15:27 不悔梦归处 阅读(233) 评论(0) 推荐(0) 编辑

2012年4月27日

Ordered Fractions

摘要: Source : UnknownTime limit : 3 secMemory limit : 32 MSubmitted : 1227, Accepted: 383Consider the set of all reduced fractions between 0 and 1 inclusive with denominators less than or equal to N.Here is the set when N = 5:0/1 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 1/1Write a program that, given an integ 阅读全文

posted @ 2012-04-27 19:06 不悔梦归处 阅读(303) 评论(0) 推荐(0) 编辑

2012年4月11日

数星星

摘要: 数星星Accepted : 63Submit : 245Time Limit : 1000 MSMemory Limit : 65536 KBDescription天空中一共有N颗星星,FF同学想知道天空中的一个矩形区域内有多少颗星星。我们把天空放到直角坐标系中,就可以得到每颗星星的坐标,假设每个星星的坐标都是整数。矩形区域我们用一个四元组表示(x1,y1,x2,y2)。x1,y1表示矩形左下角的坐标,x2,y2表示矩形右上角的坐标。现在请你回答FF同学提出的问题:矩形(x1,y1,x2,y2)内有多少颗星星(包括边界上的)。FF是个好问的同学,最多一次能提出10000个问题,请你用最快的速度 阅读全文

posted @ 2012-04-11 21:24 不悔梦归处 阅读(233) 评论(0) 推荐(0) 编辑

2012年4月10日

Humble Numbers 1095

摘要: View Code #include <iostream>using namespace std;int a[5844];int min(int b,int c,int d,int e){ int t; t=b<c?b:c; t=t<d?t:d; t=t<e?t:e; return t;}int main(){ int i=0; a[i]=1; int x=0,y=0,z=0,m=0; while(i<=5843) { a[++i]=min(a[x]*2,a[y]*3,a[z]*5,a[m]*7); if(... 阅读全文

posted @ 2012-04-10 22:37 不悔梦归处 阅读(170) 评论(0) 推荐(0) 编辑

ZOJ Problem Set - 1089 Lotto

摘要: LottoTime Limit: 2 Seconds Memory Limit: 65536 KBIn a Lotto I have ever played, one has to select 6 numbers fromView Code #include <iostream>#include <algorithm>#include <fstream>using namespace std;int main(){ // ofstream cout("1.txt"); int a[20]; int n; int cae=0; while 阅读全文

posted @ 2012-04-10 22:33 不悔梦归处 阅读(219) 评论(0) 推荐(0) 编辑

1040: Count

摘要: 1040: CountTime Limit: 1 SecMemory Limit: 128 MBSubmit: 2Solved: 2[Submit][Status][Web Board]DescriptionMany ACM team name may be very funny,such as "Complier_Error","VVVVV".Oh,wait for a minute here.Is it "W W"+"V",or "W"+"V V V",or someth 阅读全文

posted @ 2012-04-10 22:29 不悔梦归处 阅读(203) 评论(0) 推荐(0) 编辑

快速求幂模板

摘要: #include <iostream>using namespace std;struct s{int a[2][2];};int p;s work(s x,s y){s c;for (int i=0;i<2;i++){for (int j=0;j<2;j++){c.a[i][j]=0;for (int k=0;k<2;k++)c.a[i][j]+=x.a[i][k]*y.a[k][j];c.a[i][j]%=p;} }return c;}s mod(s t,int n){s m; if (n==0||n==1) {return t; }if (n%2){ m=m 阅读全文

posted @ 2012-04-10 22:13 不悔梦归处 阅读(164) 评论(0) 推荐(0) 编辑

导航