原创 SPOJ GNYR09F

#include <iostream> #include <stdio.h> using namespace std; const int N = 102; int d[N][N][2],n,m; void dp() { i

原创 1A--Theatre Square

注意:64位. #include <iostream> #include <stdio.h> using namespace std; int main() { unsigned long long n,m,a; ci

原创 CodeForces 295B

#include <iostream> #include <stdio.h> using namespace std; long long distan[502][502],del[502],ans[502]; int main()

原创 CodeForces 20C

dijkstra。唯一不同的是加入了一個記錄來源的數組,最後在主函數裏反向輸出。 #include <iostream> #include <queue> #include <memory.h> #include <fstream> us

原创 CodeForces 81A

#include <iostream> #include <string> using namespace std; const int MAXN = 300010; char cat[MAXN]; string s; int mai

原创 hdu2544

標準的dijkstra。 #include <iostream> #include <memory.h> #include <queue> using namespace std; int N,M; int v[10002],next[

原创 SPOJ NITK06

#include <iostream> using namespace std; int cat[10002]; int T,n; void fun() { for(int i = 1;i <= n - 1;i ++)

原创 hdu2503

map的應用。首先輸入一個字典,字典格式爲“英語à外語”的一一映射關係。,然後輸入若干個外語單詞,輸出他們的 英語翻譯單詞,如果字典中不存在這個單詞,則輸出“eh”。總體來說就是用map這個數據結構,還有是本題中輸入中的一些技巧,運用c的

原创 poj1724

這個題意是找到一條符合規定條件的最短路,因爲直接求最短路可能由於錢的約束而到不了。所以在求解過程中如果遇到不合題意的解直接剪掉,或者不進行後續操作而無形中終止,最後留下的符合約束條件的解,進行判斷最大的解。好像可以用dijkstra做,沒

原创 hdu1004

Map 簡介: map是一類關聯式容器。它的特點是增加和刪除節點對迭代器的影響很小,除了那個操作節點,對其他的節點都沒有什麼影響。對於迭代器來說,可以修改實值,而不能修改key。 Map的功能 1.自動建立Key - value的對應

原创 poj2503

字典樹的應用。 其實這個題可以用map很簡單的做出來,但字典樹在解決這種求解字符串匹配由於暴力求解而造成的超時的聞聽更爲明顯,所以更傾向這種方法。 #include <iostream> #include <stdio.h> #inclu

原创 CodeForces 4C

#include <iostream> #include <string> #include <map> using namespace std; int n; int main() { string str; map

原创 A New Year Gift

#include <iostream> #include <stdio.h> using namespace std; int n,m,cat[1002]; int main() { while(~scanf("%d",&n)

原创 poj3067

樹狀數組。在這裏提示兩個好習慣,輸入輸出用‘scanf‘printf’,據說比’cin’cout‘快10倍吧,第一遍就因爲這個超時,還有定義sum值時,最好用long long,畢竟不是超大數組,多幾個,可以減少不必要的麻煩,當然這個視具

原创 hdu2222

AC自動機模板。首先定義一個功能很強大的結構體,裏邊包含有關的所有的應用,再對文章進行多模式匹配。 #include <iostream> #include <stdio.h> #include <queue> #include <str