原创 Intersect

#include <iostream> #include <set> using namespace std; int main() { int n; cin>>n; while(n--) {

原创 connect components in undirected graph

深度和寬度搜索都寫了,記住分析的過程。 #include <iostream> #include <vector> #include <cstring> #include <queue> using namespace std;

原创 猴子選大王

#include <iostream> #include <list> #include <vector> using namespace std; const int maxn = 100; int data[maxn];

原创 紅與黑

#include <iostream> #include <cstring> using namespace std; const int maxn = 25; int dr[]={0,0,1,-1}; int dc[]={1,

原创 圖的廣度優先搜索

pay attention to the cout #include <iostream> #include <vector> #include <cstring> #include <queue> using namespace

原创 Team Rankings

搜索 #include <iostream> #include <cstring> using namespace std; char tmp[10]; char data[110][10]; int vis[10]; int a

原创 1002. 計算二叉查找樹的高度

devcpp代碼名字如果太相近就會出現bug #include <iostream> using namespace std; const int maxn = 100; int a[maxn],b[maxn]; struct T

原创 Sorting Algorithm

堆排序 #include <iostream> using namespace std; const int maxn = 100010; int a1[maxn]; int n,m; void g(int lo,int len)

原创 validate-binary-search-tree

while寫成if debug了半天。 /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left;

原创 list

http://www.cnblogs.com/fangyukuan/archive/2010/09/21/1832364.html http://www.cnblogs.com/scandy-yuan/archive/2013/

原创 最長句子

從子樹到父節點卻是一個選擇。 #include <set> #include <map> #include <string> #include <iostream> using namespace std; int getLen(

原创 Super Snooker

#include <iostream> using namespace std; int main() { int t; cin>>t; int a,b,c,d; for (int i=1;i<=

原创 地牢逃脫

是對最短路徑的變形,即是就最短路徑當中的最長路徑,注意修改即可。bfs,dfs都可以實現,現在附上dfs的實現方式。 #include <iostream> #include <cstring> using namespace s

原创 前序中序求後序,中序後續求前序

求後續 #include <bits/stdc++.h> using namespace std; int const maxn=1100; int a[8][8]; int vis[8]; vector<string> ans;

原创 高精度模板

#include <bits/stdc++.h> using namespace std; string add(string s1,string s2) { int l1 = s1.size(); int l2 =