hdu 1026【Ignatius and the Princess I】
摘要:广搜我用path记录路径,初始为-1,并且可以用path标记该点是否走过,如果为-1则表示没有走过,一举两得,然后用print递归输出路径。在记录路径时我是将点的坐标转化为一个数值即X*M+Y,当输出路径的时候可将path里面的值转化为坐标……代码如下: 1 #include <iostream> 2 #include <queue> 3 #include <cstdio> 4 using namespace std; 5 6 const int maxlen = 100 + 10; 7 struct place 8 { 9 int x,y; 10 in..
阅读全文
posted @
2012-07-31 11:03
Shirlies
阅读(261)
推荐(0) 编辑
hdu 1238【Substrings】
摘要:直接用string类里面的一些函数先排序,然后用最短的那个字符串的子串跟其他字符串的子串比较。。。代码如下: 1 #include <iostream> 2 #include <string> 3 #include <algorithm> 4 using namespace std; 5 6 bool cmp(const string& a,const string& b) 7 { 8 return a.size() < b.size(); 9 }10 11 void inverse(string& aim)12 {13 str
阅读全文
posted @
2012-07-26 11:04
Shirlies
阅读(268)
推荐(0) 编辑