Fork me on GitHub
摘要: 一直向前搜。。做法有点像模拟。但是要用到出队入队,有点像搜索。代码:#include #include #include #include #include #include using namespace std;#define N 100003struct node{ int p,d; bool operator a.d; return p>a.p; }}stone[N];int maxdis;priority_queue que;void GO(){ node now,next; int OE = 1; while(!que.empty(... 阅读全文
posted @ 2014-02-28 22:25 whatbeg 阅读(239) 评论(0) 推荐(0)
摘要: 优先队列。。刚开始用蠢办法,经过一个vector容器中转,这么一来一回这么多趟,肯定超时啊。超时代码如下:#include #include #include #include #include #include #include #include #include #include #include using namespace std;#define N 30003priority_queue,greater > que;int A[N];vector tmp;int main(){ int m,n,i,j,th,u,k,h; while(scanf("%d%d" 阅读全文
posted @ 2014-02-28 21:56 whatbeg 阅读(230) 评论(0) 推荐(0)
摘要: 好题。这题可以有三种解法:1.Dijkstra 2.优先队列 3.并查集我这里是优先队列的实现,以后有时间再用另两种方法做做。。方法就是每次都选当前节点所连的权值最大的边,然后BFS搜索。代码:#include #include #include #include #include #include #include #include #include #include #include using namespace std;#define N 100007struct node{ int ind,wt; bool operator mp;priority_queue qu... 阅读全文
posted @ 2014-02-28 10:33 whatbeg 阅读(317) 评论(0) 推荐(0)