摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1242用bfs做,要用优先队列#include<iostream>#include<string>#include<queue>using namespace std;int sx,sy,ex,ey;int n,m;int map[205][205];int dis[4][2]={0,1,1,0,0,-1,-1,0};struct node{ int x,y; int step; friend bool operator<(node a,node b) //优先队列必 阅读全文
posted @ 2013-05-19 22:09
努力ing
阅读(222)
评论(0)
推荐(0)
摘要:
广搜的题目http://acm.hdu.edu.cn/showproblem.php?pid=1253用优先队列会超时时间少,空间大#include<iostream>#include<queue>using namespace std;int a,b,c,t;int map[55][55][55];int dir1[2]={1,-1};int dir2[4][2]={{1,0},{0,1},{-1,0},{0,-1}};struct node{ int x,y,z; int time;};bool cmp(int v,int w,int u){ if(v<0|| 阅读全文
posted @ 2013-05-19 22:02
努力ing
阅读(128)
评论(0)
推荐(0)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1081矩阵压缩的题目#include<iostream>using namespace std;int find(int a[],int n) //找最大子序列{ int max=-10004; int i,sum=0; for(i=0;i<n;i++) { sum+=a[i]; if(sum>max) max=sum; if(sum<0) sum=0; } return max;}int main(){ int i,j,k,n; int a[150][150]; while(c 阅读全文
posted @ 2013-05-19 21:58
努力ing
阅读(125)
评论(0)
推荐(0)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1574题目大意:如果a>0并且当前rp值大于或等于b时,才有可能发生如果a<0并且当前rp值小于或等于b是,才有可能发生事件有可能不发生,有可能发生分析:以第三组数据为例:3-50410-5-5-5510初始化:rp数组INFINF…………INF0INF…………INF01l=r=10000;20005第一事件发生:因为a<0;所以b+10000到r之间都有可能发生,用for循环2rp数组INFINF……4……0INFINF……INF01l=l+a=9995;r=10000;第二事件发生:因为 阅读全文
posted @ 2013-05-19 16:50
努力ing
阅读(211)
评论(0)
推荐(1)
浙公网安备 33010602011771号