您正在查看 "Hdu" 分类下的文章 2009年08月22日 星期六 下午 9:10 广搜,没优化,就0ms过了。与上一道类似(1253)。
#include<stdio.h> #include<deque> using namespace std; int N; class |
2009年08月22日 星期六 下午 5:40 宽搜三维迷宫,需加一定的剪枝。不剪枝tle,剪的多了wa了几次。
用了很多STL有点慢。
#include<stdio.h> #include<vector> #include<deque> using namespace std |
2009年08月21日 星期五 下午 10:08 2. 按位存(char的低四位),按位与(0b1,0b10,0b100,0b1000).更快。 #include<stdio.h> #include<string.h>
const int SIZE= |
2009年08月21日 星期五 下午 9:14 并查集求集数。
存下每块地的连通性(上下左右),再遍历,如两块地连通,就合并。最后计算集合数。
两种不同的存连通性方式。
1. 用vector<bool>(4) 存上左下右。今天发现vector<bool> 是按位存的(不是字节),与bitset类似。
#include<vector> #include<stdio.h> using |
2009年08月21日 星期五 下午 4:38 先判断有没有回路,没有还要判断整个图是否联通。
#include<stdio.h> #include<string.h> int connection[100005]; bool |
2009年08月20日 星期四 上午 11:38 并查集,处理完后,要算共有几个集,集数-1就是还要盖的路数。
注意merge的方法
#include<stdio.h> int roads[1005],sets[1005] |
2009年08月19日 星期三 下午 10:37 并查集。
#include<stdio.h> int root[2005],mate[2005],nBugs,nInters |
2009年08月06日 星期四 下午 5:12 广搜,模板题。
#include<stdio.h> #include<deque> using namespace std;
int x0,y0,cnt, |
2009年08月06日 星期四 下午 2:59 原来想过广搜,做不出来。用深搜,到门到的早了就回逆,剪枝一大堆,奇偶,等等。
要把走过的路标记一下以防重走,但是如果一条路走不通,回逆前要把标记取消,让其他路走。
第一次交所有变量都用的char(为省空间)结果access violation,都改成int一次就过了。
以后注意:一定不能用char 来省空间!!!!
|
2009年08月02日 星期日 上午 11:37 比较复杂,先按字符串长度排序,再用最短的生成字串(最短的哪一个都行,但是就一个,我开始全列了一遍,结果TLE),拿字串和它的逆序串 用kmp (用朴素超时)跟其他的匹配。生子串是长度从大到小,有一个结果就输出。非常经典!
#include<iostream> #include<string> #include |
| | |