2013年12月3日

bfs+优先队列(hdu1242)

摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1242这题目就是个大坑,先说下思路就是在遇到‘x’时要多停留1步,另外就是要用到优先队列,要从小到大排列,另外就是普通的bfs了但是要注意题里的each of Angel's friend数据里其实就一个‘r’的位置,但我当多个‘r’做应该也没错就是wa想不通啊这是我按一个‘r’做的。#include#include#include #include using namespace std;struct in{ char b; int x; int y; int t;... 阅读全文

posted @ 2013-12-03 17:46 Arthas0v0 阅读(152) 评论(0) 推荐(0) 编辑

简单并差集(hdu1232)

摘要: 这就是赤果果的并差集啊,学并差集第一道做的就是做这道,直接代码。#include int bin[1002];int findx(int x){ int r=x; while(bin[r] !=r) r=bin[r]; return r;}void merge(int x,int y) //并集合{ int fx,fy; fx = findx(x); fy = findx(y); if(fx != fy) bin[fx] = fy;}int main(){ int n,m,i,x,y,count; while... 阅读全文

posted @ 2013-12-03 17:41 Arthas0v0 阅读(141) 评论(0) 推荐(0) 编辑

导航