2012年6月5日

hdu 1195 Open the Lock 双广

摘要: //题目大意:求解开4位密码锁的最少步数.//<变化一次:加1;减1;邻位交换>思路:简单bfs能过,时间很高,双bfs好点。简单bfsView Code #include <stdio.h>#include <string.h>#include <stdlib.h>#include <iostream>#include <queue>#include <algorithm>using namespace std;struct nd{ int num,st;};int hash[10000];int s,t;i 阅读全文

posted @ 2012-06-05 23:58 aigoruan 阅读(187) 评论(0) 推荐(0)

hdu3172 Virtual Friends

摘要: 很有意思的一道题:两个人成为朋友,他们就有关系,题目给出m句话,每一句是两个人,表示两个成为朋友,然后叫你求这与这两个人有关系的集合中有多少个人。以为stl过不了,结果过了,直接用map映射就好了,如果不在同一集合,就暴力合并(时间卡在这里)。注意一下这个题目的输入。View Code #include<stdio.h>#include<string.h>#include<string>#include<iostream>#include<map>#include<set>using namespace std;const 阅读全文

posted @ 2012-06-05 16:28 aigoruan 阅读(191) 评论(0) 推荐(0)

导航