2014年3月18日

noj火烧赤壁2

摘要: 这是我的一个学长出的题就是并查集但是开始没想到还能这样倒着来总之很有想法的一道题#include#include#include#includeusing namespace std;vectortt[200005];int b[200005];int cc[200005][2];int dd[200005];int xx[200005];int yy[200005];int find(int x){ if(b[x] != x) b[x] = find(b[x]); return (b[x]);}void un(int x, int y){ if(find(x)... 阅读全文

posted @ 2014-03-18 14:08 Arthas0v0 阅读(117) 评论(0) 推荐(0) 编辑

2014年3月17日

stl-pair

摘要: ACM/ICPC竞赛之STL--pair (转)STL的头文件中描述了一个看上去非常简单的模板类pair,用来表示一个二元组或元素对,并提供了按照字典序对元素对进行大小比较的比较运算符模板函数。例如,想要定义一个对象表示一个平面坐标点,则可以:pair p1;cin >> p1.first >> p1.second; pair模板类需要两个参数:首元素的数据类型和尾元素的数据类型。pair模板类对象有两个成员:first和second,分别表示首元素和尾元素。 在中已经定义了pair上的六个比较运算符:、=、==、!=,其规则是先比较first,first相等时再比较s 阅读全文

posted @ 2014-03-17 18:52 Arthas0v0 阅读(121) 评论(0) 推荐(0) 编辑

2013年12月13日

hdu1054二分图的最大匹配

摘要: 今天又做到了二分图的最大匹配的模板题感觉也可以dp做题目:http://acm.hdu.edu.cn/showproblem.php?pid=1054代码还是模板就可以了。 1 #include 2 #include 3 #include 4 int map[1505][1505]; 5 int vis[1505]; 6 int mark[1505]; 7 int n; 8 int km(int x) 9 {10 for(int i = 0; i < n; i++)11 {12 if(!map[x][i] || vis[i])13 con... 阅读全文

posted @ 2013-12-13 18:18 Arthas0v0 阅读(141) 评论(0) 推荐(0) 编辑

2013年12月5日

大数模板

摘要: 大数每次写都好麻烦这次转了一篇模板感觉不错哦转:#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int MAXL = 500; struct BigNum { int num[MAXL]; ... 阅读全文

posted @ 2013-12-05 14:25 Arthas0v0 阅读(120) 评论(0) 推荐(0) 编辑

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) 编辑

2013年12月2日

hdu1150

摘要: 二分图最大匹配的模板体,套模板就过了,但是很坑爹有木有,那个i根本没有用#include#include bool map[501][501]; int mark[501]; bool flag[501]; int k,g,m; void get_map(){ int i,x,y; for(i=0;i<k;i++) { int tt; scanf("%d%d%d",&tt, &x,&y); map[x][y]=1; }}bool dfs(int x){ int i; for(i=1;i<=m;i++) { if(!ma... 阅读全文

posted @ 2013-12-02 19:31 Arthas0v0 阅读(151) 评论(0) 推荐(0) 编辑

导航