摘要:
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) //优先队列必
阅读全文
摘要:
广搜的题目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||
阅读全文
摘要:
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
阅读全文