摘要: 题目:http://poj.org/problem?id=2251简单三维 bfs不解释, 1A, 上代码 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #include11 #include12 using namespace std;13 14 int a,b,c;15 int vis[50][50][50],G[50][50][50];16 int dx[6]={0,0,0,0,-1,1};17 int dy[6]={0,0,1,-. 阅读全文
posted @ 2013-08-26 17:30 水门 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=1321参考博客:http://blog.csdn.net/lyy289065406/article/details/6647674 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #include11 #include12 using namespace std;13 14 int n,k,cnt;15 int G[10][10],vis[10];16 17 void dfs(in. 阅读全文
posted @ 2013-08-26 16:28 水门 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=3274 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #include11 #include12 using namespace std;13 14 #define prime 10000315 int n,k,f;16 int bit[prime][32],head[prime],next[prime];17 int hash(int v[])//据说 这叫折叠法,我还是不明白. 阅读全文
posted @ 2013-08-25 22:00 水门 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=2513参考博客:http://blog.csdn.net/lyy289065406/article/details/6647445http://www.cnblogs.com/LK1994/p/3263462.html 1 #include... 阅读全文
posted @ 2013-08-24 20:39 水门 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4530dp[i]表示现在存在i个吸血鬼要达成目标(全为吸血鬼)天数的数学期望假如现在再增加一天,这一天可能会增加一个吸血鬼,p1*(dp[i+1]+1)表示接下来的一天增加了... 阅读全文
posted @ 2013-08-24 15:30 水门 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=1840题解:http://blog.csdn.net/lyy289065406/article/details/6647387小优姐讲的很好了 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 short hash[25000001]; 9 int main()10 {11 int a1,a2,a3,a4,a5;12 int x1,x2,x3,x4,x5;13 int s... 阅读全文
posted @ 2013-08-23 21:15 水门 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=2418在poj 上交题总是有各种错误,再次感叹各个编译器。c++ AC代码,G++为超时,上代码: 1 #include 2 #include 3 #include 4 using namespace std; 5 6 char s[100]; 7 int main() 8 { 9 mapmp;10 map::iterator iter;//声明迭代器11 int sum=0;12 while(gets(s)!=NULL)13 {14 mp[s]++;... 阅读全文
posted @ 2013-08-23 16:57 水门 阅读(324) 评论(1) 推荐(0) 编辑
摘要: poj double 就得交c++,我交G++错了一次题目:http://poj.org/problem?id=2151题意:ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率问 每队至少解出一题且冠军队至少解出N道题的概率。每队均至少做一题的概率P1减去每队做题数均在1到N-1之间的... 阅读全文
posted @ 2013-08-21 16:44 水门 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=2442题意:给你n*m的矩阵,然后每行取一个元素,组成一个包含n个元素的序列,一共有n^m种序列,让你求出序列和最小的前n个序列的序列和。 又是一个机智的题 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #include11 #include12 using namespace std;13 14 int a[20000],b[20000];15 int main()16 {17. 阅读全文
posted @ 2013-08-21 14:36 水门 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=1442题意:n,m,分别是a数组,u数组的个数,u[i]w为几,就加到a几,然后输出第i 小的刚开始用了一个小顶堆,超时,后来看了看别人的 代码,很巧妙的设计 1 #include 2 #include 3 4 using namespace std; 5 6 int a[40000]; 7 int main() 8 { 9 int n,i,m,j,u;10 priority_queue,less > maxhead;11 priority_queue,greater > minhead;12 sc... 阅读全文
posted @ 2013-08-21 10:13 水门 阅读(389) 评论(0) 推荐(0) 编辑
摘要: http://www.cnblogs.com/bigcat814/ http://blog.sina.com.cn/s/blog_7065a9de010154ve.html 堆 http://www.cppblog.com/MiYu/archive/2010/09/01/125539.html 以下 阅读全文
posted @ 2013-08-20 15:31 水门 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=2299这个题目实际就是求逆序数,注意 long long上白书上的模板 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include ... 阅读全文
posted @ 2013-08-20 10:01 水门 阅读(259) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=3253没用long long wrong 了一次 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #include11 using namespace std;12 13 int main()14 {15 long long n,i,j,a,sum,cnt;//或者 __int64 n,i,j,a,sum,cnt;16 priority... 阅读全文
posted @ 2013-08-19 20:50 水门 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=2503不知道为什么 poj 的 数据好像不是100000,跟周赛的不一样2000MS的代码: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #include11 using namespace std;12 13 char str[200010][30];14 int main()15 {16 int i,j;17 char s1... 阅读全文
posted @ 2013-08-19 20:17 水门 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=16110号是病原,求多少人有可能感染 1 #include 2 #include 3 #define maxn 50000 4 5 int u,v,bin[maxn]; 6 int find(int x) 7 { 8 return bin[x]==x?x:(bin[x]=find(bin[x])); 9 };10 11 int main()12 {13 int n,m,i,j,x,y,k,sum,t;14 while(~scanf("%d%d",&n,&m)&&(n!=0||m!=0 阅读全文
posted @ 2013-08-19 19:45 水门 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=1035还是暴搜 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 ... 阅读全文
posted @ 2013-08-19 19:13 水门 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=3080水题,暴搜 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #include1... 阅读全文
posted @ 2013-08-19 13:01 水门 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=3041题意:在某个n*n的空间内,分布有一些小行星,某人在里面打炮,放一枪后某一行或某一列的行星就都没了,让求最少的打炮数。然后把每行x或者每列y看成一个点,而障碍物(x,y)可以看做连接x和y的边。按照这种思路构图后。问题就转化成为选择最... 阅读全文
posted @ 2013-08-16 17:36 水门 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=3267题意:给定一个字符串,又给n个单词,求最少删除字符串里几个字母,能匹配到n个单词里 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 using namespace std;11 12 char s[700][400];13 int min_n(int a,int b)14 {15 return a>b?b:a;16 }17 int main()18 {19 i... 阅读全文
posted @ 2013-08-15 11:28 水门 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=3687题意:n个重量为1~n的球,给定一些编号间的重量比较关系,现在给每个球编号,在符合条件的前提下使得编号小的球重量小。(先保证1号球最轻,其次2号……)然后,按照重量1~n的输出位置要倒序建图,优先选择编号大的 给编号大的 拓扑排序,注... 阅读全文
posted @ 2013-08-14 17:03 水门 阅读(240) 评论(0) 推荐(0) 编辑