原创 POJ 2503 Babelfish map水過,字典樹????

map用法: map<string,string>q; 可以直接q[s1]  = s2; 這開闢了一個空間。 查找可以s.find(s1); 返回一個迭代器,指向s1 可以 ,   printf("%s\n", q[s1].c_str()

原创 POJ 2418 Hardwood Species map水過,字典樹的題目

map默認初始化爲0   按鍵字典序自動排序 讓我們一起來分析一下while(getline(cin,line))語句 注意這裏默認回車符停止讀入,按Ctrl+Z或鍵入EOF回車即可退出循環。 在這個語句中,首先getline從

原创 POJ 1840 Eqs 暴力哈希

用short #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <vector> #include <set> #

原创 POJ 3080 Blue Jeans 串的暴力

找相同的公共子串,若相同,輸出考後的子串 #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <algorithm> #inc

原创 POJ 3253 Fence Repair 優先隊列

優先隊列,每次選取兩個小的元素求和加入到隊列中,當隊列還剩下一個元素的時候,跳出即可,還有就是sum要定義成longlong #include <iostream> #include <algorithm> #include <cstdi

原创 POJ 3273 Monthly Expense 最大值最小 二分法

#include<stdio.h> #include <stdlib.h> #include <string.h> int s[112345]; int main() { int n,m,i,low,high,mid,num,

原创 POJ 3087 Shuffle'm Up 模擬題小水

用map來標記以前出現過的狀態 #include <stdio.h> #include <map> #include <string.h> #include <string> using namespace std; int main(

原创 POJ 2442 Sequence k路歸併,優先隊列

維護一個最大堆,堆裏面的就是所求前k個最小值 #include <iostream> #include <stdio.h> #include <queue> #include <algorithm> using namespace st

原创 poj 3126 Prime Path 簡單bfs

注意千位的時候要從1開始 #include <algorithm> #include <iostream> #include <stdio.h> #include <queue> #include <string.h> #include

原创 POJ 1442 Black Box 優先隊列 求前a[k]個數中第k大的數

維護兩個隊列, 開A #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <vector> #include <se

原创 POJ 1321 棋盤問題

網上代碼1: #include<stdio.h> #include<string.h> int n,k,vis[15],ans; char mat[15][15]; void dfs(int cur,int num) { if(nu

原创 POJ 2251 Dungeon Master 三維BFS

注意x,y,z的方向,簡單的BFS#include <algorithm> #include <iostream> #include <stdio.

原创 POJ 1426 Find The Multiple dfs

輸出結果有點不能理解 #include <algorithm> #include <iostream> #include <stdio.h> #include <queue> #include <string.h> using names

原创 hdu 5842 Lweb and String 字符串水題

比賽的時候硬生生的寫的Longest_increasing_subsequence,結果比賽完才知道原來就是個統計字母個數的。。。英語不好啊啊,GG~~~~ #include <stdio.h> #include <algorithm>

原创 POJ 3349 Snowflake Snow Snowflakes 哈希

第一次做哈希 直接搜的題解,就當是照着葫蘆畫瓢吧代碼如下~~~~ #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <alg