Time of Update: 2018-12-04
/*一開始題目沒有看懂,原來是象棋中的跳馬問題你不是喜歡下棋的嗎?可是為何。。。糾結這是我第一自己獨立寫的bfs, 在通過調試,終於改了自己犯的低級的毛病(標記為@的地方)*/#include<iostream>//2374758 2010-04-23 14:41:15 Accepted 1372 46MS 292K 1189 B C++ 悔惜晟 #include<queue>#include<cstdio>using namespace std;int
Time of Update: 2018-12-04
/* 這個題目分在搜尋的地方,最近一直在寫bfs dfs, 腦子中看見題目就感覺是搜, 其實這個題目很簡單的,排序 + 二分尋找就OK了 二分一直沒有寫過,都是在書本上看理論知識,理論聯絡實際, 這才是最重要的*/#include<iostream>//2395029 2010-04-28 18:42:18 Accepted 2141 390MS 1276K 1076 B C++ 悔惜晟
Time of Update: 2018-12-04
/*很明顯的深搜的題目,而且很用到了棧的知識,不錯的題目, 感覺還不是很懂,有點瓶緊的感覺,應該是對棧不是很熟悉的緣故吧, 感覺好像做過的dfs的題目好像都有特定的格式一樣的, 好好加油 */#include<iostream>#include<stack>using namespace std;char a[1000];char b[1000];bool hash[2000];int lena, lenb;stack<char> s;void
Time of Update: 2018-12-04
/* 這是看到這個題目第一次寫的代碼,但是 標記為@的地方沒有考慮,一直測試資料都過不了,怎麼回事? 為何要犯那麼糾結的錯誤呢??還有要考慮兩層都是#的情況的,其實一看題目我就想到的,我以為不要考慮的 */ #include<iostream> //2399013 2010-04-29 16:50:05 Accepted 2102 0MS 296K 2418 B C++ 悔惜晟 #include<queue>#include<cstring>#include&
Time of Update: 2018-12-04
http://acm.hdu.edu.cn/showproblem.php?pid=1863 #include<iostream>//又是最小產生樹的問題#include<algorithm>#include<cstdio>using namespace std;int s[4951]; struct stu { int x; int y; int dis; }df[4951]; int cmp(stu a, stu b) { return
Time of Update: 2018-12-04
/*本題給的n的資料很大,但是n > N 的時候的數都是不成立數論真的要好好的去學習*/#include <iostream>#include <cstdio>#include <cstring>#include <cmath>using namespace std;const int N = 10000000;bool hash[N];int path[1000000];int len;inline void
Time of Update: 2018-12-04
/* 這是很早做錯的題目,今天看了許建峰買來的書,試了下書上的STL,AC了 很強大的STL,我決定今晚全部學完,加油! 以前做這個題目的時候題目的意思讀錯的,糾結啊! 尋找一個串是否是另個的首碼?*/ #include<iostream>//2453667 2010-05-14 19:42:26 Accepted 1671 328MS 748K 577 B C++ 悔惜晟
Time of Update: 2018-12-04
#include//2367513 2010-04-21 20:22:34 Accepted 1241 15MS 340K 992 B C++ 悔惜晟using namespace std;char map[105][105];int dir[8][2] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1} };int m, n; //一開始方向寫錯了,真是糾結的。void dfs(int x,
Time of Update: 2018-12-04
//很簡單的題,就是n!<2^bit只是想提醒自己,很大數之間的比較有時候只要選擇對數就好了。求出最大的n //一開始題目讀不懂,baidu了才知道題目的意思,題目很簡單,只是題目的意思很難讀懂//2268208 2010-03-30 17:32:13 Accepted 1141 281MS 312K 285 B C++ 悔惜晟 #include<iostream>#include<cmath>using namespace std;int
Time of Update: 2018-12-04
//第一次調用棧,突然發現這是一個好東西 #include<iostream>#include<cstdio>#include<stack>using namespace std;//int num[100001];int main(){ int n, r; while(cin>>n>>r) { if(n < 0) { printf("-"); n = -n; } stack <int> q; //
Time of Update: 2018-12-04
/*逼著自己去寫鄰接表,xwc給我講過大致如何構造,聽其實還是簡單的。可是寫起來稍微有點困難的光是建表就很糾結的,指標數組 和 數組 總是不能區別開來,最初很痛苦寫好的,編譯沒有通過,把這兩個東西混起來,對於指標就是有一種莫名的不知道。很早xwc就鼓勵我去寫了,但是一直害怕麻煩就不敢嘗試,這是一個不好的毛病,為了不能讓cdd
Time of Update: 2018-12-04
/*這是上學期老師講的題目,開始聽的時候感覺有點懵懂,也就不敢嘗試的去寫, 後來發現搜尋相當重要,特別是在這段時間以來我發現搜尋不會就是菜鳥, 從這裡開始我要認真地學習搜尋 */#include<iostream>//2359309 2010-04-19 19:20:14 Accepted 1010 62MS 284K 1405 B C++ 悔惜晟 #include<cstdio> //不知道他們0秒的是怎麼實現的??using namespace std;char
Time of Update: 2018-12-04
http://acm.hdu.edu.cn/showproblem.php?pid=1213#include<iostream>//很簡單的並查集 #include<cstdio>int s[1002];//bool ss[1002]; int find(int a) { int r = a; while(r != s[r]) r = s[r]; return r; } void merge(int a, int b) { if(a > b) s[
Time of Update: 2018-12-04
/*很水的bfs,一開始bfs不會,用dfs錯了好多次,應該是演算法有問題吧,我覺得這個題目用dfs應該可以的*/#include<iostream>//2389356 2010-04-27 11:23:31 Accepted 1240 0MS 308K 1495 B C++ 悔惜晟 #include<queue>#include<cstring>#include<cmath>using namespace std;char map[12][12]
Time of Update: 2018-12-04
#include<iostream>//2365548 2010-04-21 14:16:05 Accepted 1016 500MS 300K 1160 B C++ 悔惜晟 #include<cstring>using namespace std;bool hash[40];bool hash1[25];int num[25];int n;void dfs(int count){ int j; if(count == n) { if(hash[ num[1] +
Time of Update: 2018-12-04
/*http://qzc.zgz.cn/Y-jiulianhuan3.htm原來這是一個遊戲記從始點到前k個環在上用f(k)步,考慮怎麼上這前k個環呢?可以先上前k-1個環,用f(k-1)步,再下前k-2個環,用f(k-2)步。此時僅有第k-1個環在上,可以進行動作Q上k號環,用1步,然後再上前k-2個環,用f(k-2)步。f(k)就是以上各個動作所需步數的和,f(k)=f(k-1)+f(k-2)+1+f(k-2) =f(k-1)+2f(k-2)+1即 f(k) =f(k-1)+2f(k-2
Time of Update: 2018-12-04
/* 終於AC了,很簡單的bfs,我居然卡了那麼久,結果居然是我題目的意思看錯了, there is a number Ki(0 <= Ki <= N) on every floor 這句話沒有認真讀, 我以為是up down 是按題目給我們的順序按的,結果第一次超記憶體,後來用hash標記,wrong。。。 後來終於看見那句要命的話了。讀懂題目方能開始做題目,切記!! */#include<iostream>//2393959 2010-04-28 1
Time of Update: 2018-12-04
http://acm.hdu.edu.cn/showproblem.php?pid=2206//在wrong 10次後終於AC//為何簡單的題目要考慮這麼久? #include<iostream>//2265653 2010-03-29 21:34:12 Accepted 2206 0MS 228K 1452 B C++ 悔惜晟 #include<string>#include<cstdio>using namespace std;int
Time of Update: 2018-12-04
http://acm.hdu.edu.cn/showproblem.php?pid=1022//學了資料結構,一點也不會用,好鬱悶的;//這是棧很基礎的內容,參考了別人的,終於寫起來有點感覺// 3 123 123 123 213 這兩種情況是可以的#include<iostream>//2275912 2010-03-31 22:18:55 Accepted 1022 0MS 352K 831 B C++ 悔惜晟 #include<cstdio>using
Time of Update: 2018-12-04
/* 1y 不錯的,昨天聽鐘超分析了dfs bdf 感覺好像有點懂起來了 這個題目的意思很簡單,一開始我想深搜的時候怕逾時,但是還是覺得可以,就敲代碼了, 可是遇到問題了,這個題目的行列輸入跟平時的不一樣,在這裡的就用了,傳統的習慣,糾結ing 跟糾結的@的地方用了map[si][sj] = false 結果答案少了1,後來進行調試,也是鐘超哪裡學來的 於是馬上發現錯誤了 */#include<iostream>//2374171 2010-04-23 12:59:2