diff --git a/.idea/acm-cheat-sheet.iml b/.idea/acm-cheat-sheet.iml
new file mode 100644
index 0000000..e28549d
--- /dev/null
+++ b/.idea/acm-cheat-sheet.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..96cc43e
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..d821048
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..699f6ac
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..c1dec64
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml
new file mode 100644
index 0000000..922003b
--- /dev/null
+++ b/.idea/scopes/scope_settings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/C++/abstract.tex b/C++/abstract.tex
index 939fb10..e5fa328 100644
--- a/C++/abstract.tex
+++ b/C++/abstract.tex
@@ -9,6 +9,8 @@ \subsubsection{内容简介}
全书的代码,使用“纯C + STL”的风格。本书中的代码规范,跟在公司中的工程规范略有不同,为了使代码短(方便迅速实现):
+
+test file
\begindot
\item 所有代码都是单一文件。这是因为一般OJ网站,提交代码的时候只有一个文本框,如果还是
按照标准做法,比如分为头文件.h和源代码.cpp,无法在网站上提交;
diff --git a/C++/diagrams/Tower-of-Hanoi.png b/C++/diagrams/Tower-of-Hanoi.png
index 1d99104..8cfc98c 100644
Binary files a/C++/diagrams/Tower-of-Hanoi.png and b/C++/diagrams/Tower-of-Hanoi.png differ
diff --git a/C++/diagrams/bigintmul1.png b/C++/diagrams/bigintmul1.png
index 0f39cb0..bb9780f 100644
Binary files a/C++/diagrams/bigintmul1.png and b/C++/diagrams/bigintmul1.png differ
diff --git a/C++/diagrams/bigintmul2.png b/C++/diagrams/bigintmul2.png
index a2b9110..586974c 100644
Binary files a/C++/diagrams/bigintmul2.png and b/C++/diagrams/bigintmul2.png differ
diff --git a/C++/diagrams/bigintmul3.png b/C++/diagrams/bigintmul3.png
index fca2028..4dd241c 100644
Binary files a/C++/diagrams/bigintmul3.png and b/C++/diagrams/bigintmul3.png differ
diff --git a/C++/diagrams/bigintmul4.png b/C++/diagrams/bigintmul4.png
index 5e239cd..bfecb00 100644
Binary files a/C++/diagrams/bigintmul4.png and b/C++/diagrams/bigintmul4.png differ
diff --git a/C++/diagrams/bigintmul5.png b/C++/diagrams/bigintmul5.png
index bdc258e..2a990ba 100644
Binary files a/C++/diagrams/bigintmul5.png and b/C++/diagrams/bigintmul5.png differ
diff --git a/C++/diagrams/blackwhite-image.jpg b/C++/diagrams/blackwhite-image.jpg
index 5f5b096..7961f87 100644
Binary files a/C++/diagrams/blackwhite-image.jpg and b/C++/diagrams/blackwhite-image.jpg differ
diff --git a/C++/diagrams/bubblesort.png b/C++/diagrams/bubblesort.png
index 53c46c6..627aea2 100644
Binary files a/C++/diagrams/bubblesort.png and b/C++/diagrams/bubblesort.png differ
diff --git a/C++/diagrams/chessboard.png b/C++/diagrams/chessboard.png
index 57ddecf..1c62885 100644
Binary files a/C++/diagrams/chessboard.png and b/C++/diagrams/chessboard.png differ
diff --git a/C++/diagrams/criticalpath.png b/C++/diagrams/criticalpath.png
index 16066c3..6022d49 100644
Binary files a/C++/diagrams/criticalpath.png and b/C++/diagrams/criticalpath.png differ
diff --git a/C++/diagrams/dijkstra.png b/C++/diagrams/dijkstra.png
index e6452a2..e83c950 100644
Binary files a/C++/diagrams/dijkstra.png and b/C++/diagrams/dijkstra.png differ
diff --git a/C++/diagrams/eight-digits.png b/C++/diagrams/eight-digits.png
index 00d159d..b2da04c 100644
Binary files a/C++/diagrams/eight-digits.png and b/C++/diagrams/eight-digits.png differ
diff --git a/C++/diagrams/eight-queen.png b/C++/diagrams/eight-queen.png
index 3b8235a..a2297e8 100644
Binary files a/C++/diagrams/eight-queen.png and b/C++/diagrams/eight-queen.png differ
diff --git a/C++/diagrams/floyd.png b/C++/diagrams/floyd.png
index 2f49248..dfe4046 100644
Binary files a/C++/diagrams/floyd.png and b/C++/diagrams/floyd.png differ
diff --git a/C++/diagrams/gallery.png b/C++/diagrams/gallery.png
index 2fb4a7d..99c1f0a 100644
Binary files a/C++/diagrams/gallery.png and b/C++/diagrams/gallery.png differ
diff --git a/C++/diagrams/horse.png b/C++/diagrams/horse.png
index 45783cd..6234f24 100644
Binary files a/C++/diagrams/horse.png and b/C++/diagrams/horse.png differ
diff --git a/C++/diagrams/inorder-morris-traversal.png b/C++/diagrams/inorder-morris-traversal.png
index 746ad7f..1662cd0 100644
Binary files a/C++/diagrams/inorder-morris-traversal.png and b/C++/diagrams/inorder-morris-traversal.png differ
diff --git a/C++/diagrams/kruskal1.png b/C++/diagrams/kruskal1.png
index efa956c..2ba8df5 100644
Binary files a/C++/diagrams/kruskal1.png and b/C++/diagrams/kruskal1.png differ
diff --git a/C++/diagrams/kruskal2.png b/C++/diagrams/kruskal2.png
index e58ab14..b7039f5 100644
Binary files a/C++/diagrams/kruskal2.png and b/C++/diagrams/kruskal2.png differ
diff --git a/C++/diagrams/lplate.png b/C++/diagrams/lplate.png
index 9cc0d1d..5e5e69b 100644
Binary files a/C++/diagrams/lplate.png and b/C++/diagrams/lplate.png differ
diff --git a/C++/diagrams/maze.png b/C++/diagrams/maze.png
index 46e9e9a..5b7de83 100644
Binary files a/C++/diagrams/maze.png and b/C++/diagrams/maze.png differ
diff --git a/C++/diagrams/mergesort.png b/C++/diagrams/mergesort.png
index 6246af0..45679c2 100644
Binary files a/C++/diagrams/mergesort.png and b/C++/diagrams/mergesort.png differ
diff --git a/C++/diagrams/next-permutation.png b/C++/diagrams/next-permutation.png
index cc9b729..0dd2335 100644
Binary files a/C++/diagrams/next-permutation.png and b/C++/diagrams/next-permutation.png differ
diff --git a/C++/diagrams/numbers-triangle.png b/C++/diagrams/numbers-triangle.png
index 51fd44c..cf1ba8c 100644
Binary files a/C++/diagrams/numbers-triangle.png and b/C++/diagrams/numbers-triangle.png differ
diff --git a/C++/diagrams/postorder-morris-traversal.png b/C++/diagrams/postorder-morris-traversal.png
index d19bffa..eb3f377 100644
Binary files a/C++/diagrams/postorder-morris-traversal.png and b/C++/diagrams/postorder-morris-traversal.png differ
diff --git a/C++/diagrams/preorder-morris-traversal.png b/C++/diagrams/preorder-morris-traversal.png
index 493946a..3c3b8d1 100644
Binary files a/C++/diagrams/preorder-morris-traversal.png and b/C++/diagrams/preorder-morris-traversal.png differ
diff --git a/C++/diagrams/prim1.png b/C++/diagrams/prim1.png
index 453f1b0..0bf357f 100644
Binary files a/C++/diagrams/prim1.png and b/C++/diagrams/prim1.png differ
diff --git a/C++/diagrams/prim2.png b/C++/diagrams/prim2.png
index 4472a19..d6276e0 100644
Binary files a/C++/diagrams/prim2.png and b/C++/diagrams/prim2.png differ
diff --git a/C++/diagrams/prim3.png b/C++/diagrams/prim3.png
index 0bff379..ff80fe4 100644
Binary files a/C++/diagrams/prim3.png and b/C++/diagrams/prim3.png differ
diff --git a/C++/diagrams/radixsort.png b/C++/diagrams/radixsort.png
index cdbabbb..6375b8c 100644
Binary files a/C++/diagrams/radixsort.png and b/C++/diagrams/radixsort.png differ
diff --git a/C++/diagrams/radixsorta.png b/C++/diagrams/radixsorta.png
index 4fbee65..8ac3d04 100644
Binary files a/C++/diagrams/radixsorta.png and b/C++/diagrams/radixsorta.png differ
diff --git a/C++/diagrams/radixsortb.png b/C++/diagrams/radixsortb.png
index a392bea..74b8aeb 100644
Binary files a/C++/diagrams/radixsortb.png and b/C++/diagrams/radixsortb.png differ
diff --git a/C++/diagrams/radixsortc.png b/C++/diagrams/radixsortc.png
index 2a531d4..209355f 100644
Binary files a/C++/diagrams/radixsortc.png and b/C++/diagrams/radixsortc.png differ
diff --git a/C++/diagrams/radixsortd.png b/C++/diagrams/radixsortd.png
index d387e24..d7ea403 100644
Binary files a/C++/diagrams/radixsortd.png and b/C++/diagrams/radixsortd.png differ
diff --git a/C++/diagrams/radixsorte.png b/C++/diagrams/radixsorte.png
index 1c33070..9530e3b 100644
Binary files a/C++/diagrams/radixsorte.png and b/C++/diagrams/radixsorte.png differ
diff --git a/C++/diagrams/radixsortf.png b/C++/diagrams/radixsortf.png
index 0109cf0..5d393bd 100644
Binary files a/C++/diagrams/radixsortf.png and b/C++/diagrams/radixsortf.png differ
diff --git a/C++/diagrams/radixsortg.png b/C++/diagrams/radixsortg.png
index faf999b..e43423b 100644
Binary files a/C++/diagrams/radixsortg.png and b/C++/diagrams/radixsortg.png differ
diff --git a/C++/diagrams/river.png b/C++/diagrams/river.png
index 2693a8a..2e35926 100644
Binary files a/C++/diagrams/river.png and b/C++/diagrams/river.png differ
diff --git a/C++/diagrams/roundrobin.png b/C++/diagrams/roundrobin.png
index 127d784..e6eb5c0 100644
Binary files a/C++/diagrams/roundrobin.png and b/C++/diagrams/roundrobin.png differ
diff --git a/C++/diagrams/shellsort.png b/C++/diagrams/shellsort.png
index efb9cfe..a06cd75 100644
Binary files a/C++/diagrams/shellsort.png and b/C++/diagrams/shellsort.png differ
diff --git a/C++/diagrams/threaded-binary-tree.png b/C++/diagrams/threaded-binary-tree.png
index ae08d6a..fbe8030 100644
Binary files a/C++/diagrams/threaded-binary-tree.png and b/C++/diagrams/threaded-binary-tree.png differ
diff --git a/C++/diagrams/ufs1.png b/C++/diagrams/ufs1.png
index 0836aeb..ced721e 100644
Binary files a/C++/diagrams/ufs1.png and b/C++/diagrams/ufs1.png differ
diff --git a/C++/diagrams/ufs2.png b/C++/diagrams/ufs2.png
index 7834f63..474df93 100644
Binary files a/C++/diagrams/ufs2.png and b/C++/diagrams/ufs2.png differ
diff --git a/C++/diagrams/ufs3.png b/C++/diagrams/ufs3.png
index a49fff9..6643f8a 100644
Binary files a/C++/diagrams/ufs3.png and b/C++/diagrams/ufs3.png differ
diff --git a/C++/diagrams/uva10054.png b/C++/diagrams/uva10054.png
index 000661a..c1be84e 100644
Binary files a/C++/diagrams/uva10054.png and b/C++/diagrams/uva10054.png differ
diff --git a/C++/src/maxNetProfit.cpp b/C++/src/maxNetProfit.cpp
new file mode 100644
index 0000000..d2629dc
--- /dev/null
+++ b/C++/src/maxNetProfit.cpp
@@ -0,0 +1,89 @@
+#include
+using namespace std;
+/*
+Author: Jiankai Sun
+Date: 2014.10.15
+*/
+/*
+N jobs are to be scheduled for processing on one machine. Job i, 1 ≤ i ≤ N,
+needs ti units of processing time. If job i is finished by time T, where T is a given
+deadline, then a profit pi is earned; otherwise, a penalty qi
+is imposed. (Both pi and qi are positive integers.) We want to select a subset S of jobs such that
+(i) ∑i∈S ti ≤ T, and (ii) f(S) = ∑i∈S pi −∑i /∈S qi is maximum.
+Show how to find such a set of jobs using dynamic programming.
+*/
+int const N=3;
+int const T=6;
+//profit
+int p[N]={12,3,4};
+//penalty
+int q[N]={1,4,2};
+//time consuming
+int t[N]={1,4,3};
+//net profit table
+int f[N+1][T+1];
+//pointer to index which job should be scheduled
+int P[N+1][T+1];
+
+void findMaxNetProfit(){
+ //non recursive implementation
+ for(int i=0;il){
+ f[k][l]=f[k-1][l]-q[i];
+ }
+ else{
+ f[k][l]=max(f[k-1][l]-q[i],f[k-1][l-t[i]]+p[i]);
+ if(f[k][l]==f[k-1][l-t[i]]+p[i]){
+ P[k][l]=1;
+ }
+ }
+ }
+ }
+ cout<<"net profit is "<deadline){
+ return findMaxNetProfit_rec(job_n-1,deadline)-q[job_n-1];
+ }
+ else{
+ int a=findMaxNetProfit_rec(job_n-1,deadline)-q[job_n-1];
+ int b=findMaxNetProfit_rec(job_n-1,deadline-t[job_n-1])+p[job_n-1];
+ if(b>a)
+ P[job_n][deadline]=1;
+ return max(a,b);
+ }
+
+}
+void printJobSet(){
+ int l=T;
+ for(int i=N;i>=1;i--){
+ if(P[i][l]==1){
+ cout<<"job "<
+using namespace std;
+//find the largest j which makes f[j]<=s[i]
+int find_opt(double [], double [],int);
+//return the maximum sum of the selected intervals
+//non recurssive version
+double max_select_nonrec(double [],double [],int);
+//recurssive version
+double max_select_rec(double [],double [],int);
+//void print selected intervals
+void print_interval(int *,int);
+
+int find_opt(double s[],double f[],int i){
+ for(int j=i-1;j>=0;j--){
+ if(f[j]<=s[i]){
+ return j;
+ }
+ }
+ return 0;
+}
+
+double max_select_nonrec(double s[], double f[],int n){
+ double * T=new double[n];
+ int * P=new int[n];
+ for(int i=0;i=T[i-1]){
+ T[i]=temp;
+ P[i]=j;
+ }
+ else{
+ T[i]=T[i-1];
+ P[i]=-1;
+ }
+
+ }
+ //print
+ print_interval(P,n);
+ return T[n-1];
+}
+void print_interval(int * P, int n){
+ int i=n-1;
+ while(P[i]!=0){
+ if(P[i]>0){
+ cout<
+using namespace std;
+/*
+Author: Jiankai Sun
+Date: 2014/10/14
+*/
+/*
+Let A=a1a2...am and B=b1b2...bn be two strings of characers. we
+want to transform A into B using following operations:
+delete a character
+and a character
+change a character
+write a dynamic programming algorithm that finds the minimum number
+of operations needed to transform A into B
+*/
+int min_ope(char * c1,const int m, char *c2,const int n){
+
+ int F[m+1][n+1];//define operation matrix
+
+ //boundary condition
+ for(int i=0;i<=m;i++){
+ F[i][0]=i;
+ }
+ for(int i=0;i<=n;i++){
+ F[0][i]=i;
+ }
+ for(int i=0;iT(i-1)}
+
+T[i]=T(p(i))+$f_i$-$s_i$
+
+P[i]=p(i)
+\Else
+
+T[i]=T[i-1]
+
+P[i]=-1
+
+\EndIf
+\EndFor
+\State Return T[n]
+\end{algorithmic}
+\end{algorithm}
+\item we use $P[1,2,...,n]$ to print selected intervals
+
+\begin{algorithm}[H]
+\caption{function printInterval() }
+\begin{algorithmic}[1]
+\State global $P[1,...,n]$
+\State i=n
+\While{P[i] $\neq$ 0}
+\If{P[i] $>$ 0}
+
+print i
+
+
+i=P[i]
+
+\EndIf
+\EndWhile
+
+\State print i
+
+\end{algorithmic}
+\end{algorithm}
+\item We use $O(nlog(n))$ to sort. For each $i$ we need $O(n)$ to scan all the interval list and repeat $n$ times, So the time complexity is $O(n^2)$
+\item source code: max\_selected\_intervals.cpp
+\end{enumerate}
+\begin{question}{2}
+Let $A=a_1a_2...a_m$ and $B=b_1b_2...b_n$ be two strings of characers. we
+want to transform $A$ into $B$ using following operations:
+
+delete a character
+
+add a character
+
+change a character
+
+write a dynamic programming algorithm that finds the minimum number of operations needed to transform $A $into $B$
+\end{question}
+\begin{enumerate}
+\item Let F[i,j] denotes the minimum number of operations needed to transform $a_1a_2...a_i$ to $b_1b_2...b_j$.
+\item Recurrence relation
+
+$
+F[i,j]=or
+\begin{cases}
+F[i-1,j-1]; if a_i=b_j\\
+min
+\begin{cases}
+F[i-1,j-1]+1; change\\
+F[i,j-1]+1; add\\
+F[i-1,j]+1; delete\\
+\end{cases}
+otherwise
+\end{cases}
+$
+
+\item Boundary conditions
+
+$F[0,k]=k$ for k in [0,n]
+
+$F[k,0]=k$ for k in [0,m]
+
+ \item implement the non recursive algorithm, see algorithm \ref{algminnum}
+
+\begin{algorithm}[H]
+\caption{function MinNumOper() }
+\label{algminnum}
+\begin{algorithmic}[1]
+\State global $F[1...m;1..n]$, A[1...m], B[1...n]
+\State Initialize $F[0,k]=k$ for k in [0,n] and $F[k,0]=k$ for k in [0,m]
+ \For{i $\leftarrow$ 1 to m}
+ \For {j $\leftarrow$ 1 to n}
+ \If {A[i]==B[j]} F[i,j]=F[i-1,j-1]
+ \Else
+
+ $
+F[i,j]=min
+\begin{cases}
+F[i-1,j-1]+1; change\\
+F[i,j-1]+1; add\\
+F[i-1,j]+1; delete\\
+\end{cases}
+$
+ \EndIf
+ \EndFor
+\EndFor
+ \State return F[m,n]
+\end{algorithmic}
+\end{algorithm}
+\item in the main function, we can call the function $MinNumOper()$ to to find the minimum number of operations needed to transform A into B
+\item time complexity of this algorithm is $\Theta(mn)$
+\item source code: min\_operation\_dp.cpp
+\end{enumerate}
+%--------------------------------------------------------------
+% You don't have to mess with anything below this line.
+% --------------------------------------------------------------
+
+\end{document}
\ No newline at end of file
diff --git a/C/diagrams/Tower-of-Hanoi.png b/C/diagrams/Tower-of-Hanoi.png
index 1d99104..8cfc98c 100644
Binary files a/C/diagrams/Tower-of-Hanoi.png and b/C/diagrams/Tower-of-Hanoi.png differ
diff --git a/C/diagrams/bigintmul1.png b/C/diagrams/bigintmul1.png
index 0f39cb0..bb9780f 100644
Binary files a/C/diagrams/bigintmul1.png and b/C/diagrams/bigintmul1.png differ
diff --git a/C/diagrams/bigintmul2.png b/C/diagrams/bigintmul2.png
index a2b9110..586974c 100644
Binary files a/C/diagrams/bigintmul2.png and b/C/diagrams/bigintmul2.png differ
diff --git a/C/diagrams/bigintmul3.png b/C/diagrams/bigintmul3.png
index fca2028..4dd241c 100644
Binary files a/C/diagrams/bigintmul3.png and b/C/diagrams/bigintmul3.png differ
diff --git a/C/diagrams/bigintmul4.png b/C/diagrams/bigintmul4.png
index 5e239cd..bfecb00 100644
Binary files a/C/diagrams/bigintmul4.png and b/C/diagrams/bigintmul4.png differ
diff --git a/C/diagrams/bigintmul5.png b/C/diagrams/bigintmul5.png
index bdc258e..2a990ba 100644
Binary files a/C/diagrams/bigintmul5.png and b/C/diagrams/bigintmul5.png differ
diff --git a/C/diagrams/blackwhite-image.jpg b/C/diagrams/blackwhite-image.jpg
index 5f5b096..7961f87 100644
Binary files a/C/diagrams/blackwhite-image.jpg and b/C/diagrams/blackwhite-image.jpg differ
diff --git a/C/diagrams/bubblesort.png b/C/diagrams/bubblesort.png
index 53c46c6..627aea2 100644
Binary files a/C/diagrams/bubblesort.png and b/C/diagrams/bubblesort.png differ
diff --git a/C/diagrams/chessboard.png b/C/diagrams/chessboard.png
index 57ddecf..1c62885 100644
Binary files a/C/diagrams/chessboard.png and b/C/diagrams/chessboard.png differ
diff --git a/C/diagrams/criticalpath.png b/C/diagrams/criticalpath.png
index 16066c3..6022d49 100644
Binary files a/C/diagrams/criticalpath.png and b/C/diagrams/criticalpath.png differ
diff --git a/C/diagrams/dijkstra.png b/C/diagrams/dijkstra.png
index e6452a2..e83c950 100644
Binary files a/C/diagrams/dijkstra.png and b/C/diagrams/dijkstra.png differ
diff --git a/C/diagrams/eight-digits.png b/C/diagrams/eight-digits.png
index 00d159d..b2da04c 100644
Binary files a/C/diagrams/eight-digits.png and b/C/diagrams/eight-digits.png differ
diff --git a/C/diagrams/eight-queen.png b/C/diagrams/eight-queen.png
index 3b8235a..a2297e8 100644
Binary files a/C/diagrams/eight-queen.png and b/C/diagrams/eight-queen.png differ
diff --git a/C/diagrams/floyd.png b/C/diagrams/floyd.png
index 2f49248..dfe4046 100644
Binary files a/C/diagrams/floyd.png and b/C/diagrams/floyd.png differ
diff --git a/C/diagrams/gallery.png b/C/diagrams/gallery.png
index 2fb4a7d..99c1f0a 100644
Binary files a/C/diagrams/gallery.png and b/C/diagrams/gallery.png differ
diff --git a/C/diagrams/horse.png b/C/diagrams/horse.png
index 45783cd..6234f24 100644
Binary files a/C/diagrams/horse.png and b/C/diagrams/horse.png differ
diff --git a/C/diagrams/inorder-morris-traversal.png b/C/diagrams/inorder-morris-traversal.png
index 746ad7f..1662cd0 100644
Binary files a/C/diagrams/inorder-morris-traversal.png and b/C/diagrams/inorder-morris-traversal.png differ
diff --git a/C/diagrams/kruskal1.png b/C/diagrams/kruskal1.png
index efa956c..2ba8df5 100644
Binary files a/C/diagrams/kruskal1.png and b/C/diagrams/kruskal1.png differ
diff --git a/C/diagrams/kruskal2.png b/C/diagrams/kruskal2.png
index e58ab14..b7039f5 100644
Binary files a/C/diagrams/kruskal2.png and b/C/diagrams/kruskal2.png differ
diff --git a/C/diagrams/lplate.png b/C/diagrams/lplate.png
index 9cc0d1d..5e5e69b 100644
Binary files a/C/diagrams/lplate.png and b/C/diagrams/lplate.png differ
diff --git a/C/diagrams/maze.png b/C/diagrams/maze.png
index 46e9e9a..5b7de83 100644
Binary files a/C/diagrams/maze.png and b/C/diagrams/maze.png differ
diff --git a/C/diagrams/mergesort.png b/C/diagrams/mergesort.png
index 6246af0..45679c2 100644
Binary files a/C/diagrams/mergesort.png and b/C/diagrams/mergesort.png differ
diff --git a/C/diagrams/next-permutation.png b/C/diagrams/next-permutation.png
index cc9b729..0dd2335 100644
Binary files a/C/diagrams/next-permutation.png and b/C/diagrams/next-permutation.png differ
diff --git a/C/diagrams/numbers-triangle.png b/C/diagrams/numbers-triangle.png
index 51fd44c..cf1ba8c 100644
Binary files a/C/diagrams/numbers-triangle.png and b/C/diagrams/numbers-triangle.png differ
diff --git a/C/diagrams/postorder-morris-traversal.png b/C/diagrams/postorder-morris-traversal.png
index d19bffa..eb3f377 100644
Binary files a/C/diagrams/postorder-morris-traversal.png and b/C/diagrams/postorder-morris-traversal.png differ
diff --git a/C/diagrams/preorder-morris-traversal.png b/C/diagrams/preorder-morris-traversal.png
index 493946a..3c3b8d1 100644
Binary files a/C/diagrams/preorder-morris-traversal.png and b/C/diagrams/preorder-morris-traversal.png differ
diff --git a/C/diagrams/prim1.png b/C/diagrams/prim1.png
index 453f1b0..0bf357f 100644
Binary files a/C/diagrams/prim1.png and b/C/diagrams/prim1.png differ
diff --git a/C/diagrams/prim2.png b/C/diagrams/prim2.png
index 4472a19..d6276e0 100644
Binary files a/C/diagrams/prim2.png and b/C/diagrams/prim2.png differ
diff --git a/C/diagrams/prim3.png b/C/diagrams/prim3.png
index 0bff379..ff80fe4 100644
Binary files a/C/diagrams/prim3.png and b/C/diagrams/prim3.png differ
diff --git a/C/diagrams/radixsort.png b/C/diagrams/radixsort.png
index cdbabbb..6375b8c 100644
Binary files a/C/diagrams/radixsort.png and b/C/diagrams/radixsort.png differ
diff --git a/C/diagrams/radixsorta.png b/C/diagrams/radixsorta.png
index 4fbee65..8ac3d04 100644
Binary files a/C/diagrams/radixsorta.png and b/C/diagrams/radixsorta.png differ
diff --git a/C/diagrams/radixsortb.png b/C/diagrams/radixsortb.png
index a392bea..74b8aeb 100644
Binary files a/C/diagrams/radixsortb.png and b/C/diagrams/radixsortb.png differ
diff --git a/C/diagrams/radixsortc.png b/C/diagrams/radixsortc.png
index 2a531d4..209355f 100644
Binary files a/C/diagrams/radixsortc.png and b/C/diagrams/radixsortc.png differ
diff --git a/C/diagrams/radixsortd.png b/C/diagrams/radixsortd.png
index d387e24..d7ea403 100644
Binary files a/C/diagrams/radixsortd.png and b/C/diagrams/radixsortd.png differ
diff --git a/C/diagrams/radixsorte.png b/C/diagrams/radixsorte.png
index 1c33070..9530e3b 100644
Binary files a/C/diagrams/radixsorte.png and b/C/diagrams/radixsorte.png differ
diff --git a/C/diagrams/radixsortf.png b/C/diagrams/radixsortf.png
index 0109cf0..5d393bd 100644
Binary files a/C/diagrams/radixsortf.png and b/C/diagrams/radixsortf.png differ
diff --git a/C/diagrams/radixsortg.png b/C/diagrams/radixsortg.png
index faf999b..e43423b 100644
Binary files a/C/diagrams/radixsortg.png and b/C/diagrams/radixsortg.png differ
diff --git a/C/diagrams/river.png b/C/diagrams/river.png
index 2693a8a..2e35926 100644
Binary files a/C/diagrams/river.png and b/C/diagrams/river.png differ
diff --git a/C/diagrams/roundrobin.png b/C/diagrams/roundrobin.png
index 127d784..e6eb5c0 100644
Binary files a/C/diagrams/roundrobin.png and b/C/diagrams/roundrobin.png differ
diff --git a/C/diagrams/shellsort.png b/C/diagrams/shellsort.png
index efb9cfe..a06cd75 100644
Binary files a/C/diagrams/shellsort.png and b/C/diagrams/shellsort.png differ
diff --git a/C/diagrams/threaded-binary-tree.png b/C/diagrams/threaded-binary-tree.png
index ae08d6a..fbe8030 100644
Binary files a/C/diagrams/threaded-binary-tree.png and b/C/diagrams/threaded-binary-tree.png differ
diff --git a/C/diagrams/ufs1.png b/C/diagrams/ufs1.png
index 0836aeb..ced721e 100644
Binary files a/C/diagrams/ufs1.png and b/C/diagrams/ufs1.png differ
diff --git a/C/diagrams/ufs2.png b/C/diagrams/ufs2.png
index 7834f63..474df93 100644
Binary files a/C/diagrams/ufs2.png and b/C/diagrams/ufs2.png differ
diff --git a/C/diagrams/ufs3.png b/C/diagrams/ufs3.png
index a49fff9..6643f8a 100644
Binary files a/C/diagrams/ufs3.png and b/C/diagrams/ufs3.png differ
diff --git a/C/diagrams/uva10054.png b/C/diagrams/uva10054.png
index 000661a..c1be84e 100644
Binary files a/C/diagrams/uva10054.png and b/C/diagrams/uva10054.png differ
diff --git a/code/chatper9/WordLadder/WordLadder.cpp b/code/chatper9/WordLadder/WordLadder.cpp
new file mode 100644
index 0000000..9e4027b
--- /dev/null
+++ b/code/chatper9/WordLadder/WordLadder.cpp
@@ -0,0 +1,76 @@
+/*
+ * WordLadder.cpp
+ * Copyright (C) 2015 ray
+ *
+ * Distributed under terms of the MIT license.
+ */
+#include
+#include
+#include
+
+using namespace std;
+
+class Solution {
+ public:
+ int ladderLength(const string& start, const string &end,
+ const unordered_set &dict) {
+ queue current, next;
+ unordered_set visited;
+
+ int level = 0;
+ bool found = false;
+ auto state_is_target = [&](const string &s) {return s == end; };
+ auto state_extend = [&] (const string &s) {
+ vector result;
+
+ for(size_t i=0; i0||new_word==end)&&
+ !visited.count(new_word)){
+ result.push_back(new_word);
+ visited.insert(new_word);
+ }
+ swap(c, new_word[i]);
+ }
+ }
+ return result;
+ };
+
+ current.push(start);
+ while(!current.empty()&&!found){
+ ++level;
+ while(!current.empty()&&!found){
+ const string str= current.front();
+ current.pop();
+
+ const auto& new_states = state_extend(str);
+ for(const auto& state: new_states){
+ next.push(state);
+ if(state_is_target(state)){
+ found = true;
+ break;
+ }
+ }
+ }
+ swap(next, current);
+ }
+ if(found) return level+1;
+ else return 0;
+ }
+};
+
+int main() {
+ Solution sol;
+ unordered_set dict = {"hot", "dot", "dog", "lot", "log"};
+ cout << sol.ladderLength("hit", "cog", dict) << endl;
+ return 0;
+}
+
+
+
+
diff --git a/code/chatper9/WordLadder/a.out b/code/chatper9/WordLadder/a.out
new file mode 100755
index 0000000..24017bc
Binary files /dev/null and b/code/chatper9/WordLadder/a.out differ
diff --git a/index.rst b/index.rst
new file mode 100644
index 0000000..a7acee3
--- /dev/null
+++ b/index.rst
@@ -0,0 +1,83 @@
+# ACM Cheat Sheet
+-----------------
+## PDF下载
+ACM Cheat Sheet(C).pdf
+
+ACM Cheat Sheet(C++).pdf
+
+C 文件夹下是C版,内容一摸一样,代码是用纯C写的,
+
+C++ 文件夹下是C++版,内容一摸一样,代码是用C++写的,
+
+Java 文件夹下是Java版,内容一摸一样,代码是用Java写的
+
+## LaTeX模板
+本书使用的是陈硕开源的[模板](https://github.com/chenshuo/typeset)。该模板已经用于陈硕写的书[《Linux 多线程服务端编程:使用 muduo C++ 网络库》](http://chenshuo.com/book/),已经出版。
+
+这个模板制作精良,很有taste,感谢陈硕 :)
+
+## 在Windows下编译
+1. 安装Tex Live 2016 。把bin目录例如`D:\texlive\2016\bin\win32`加入PATH环境变量。
+1. 安装字体。这个LaTex模板总共使用了9个字体,下载地址 ,有的字体Windows自带了,有的字体Ubuntu自带了,但都不全,还是一次性安装完所有字体比较方便。
+1. 安装TeXstudio
+1. (可选)启动Tex Live Manager,更新所有已安装的软件包。
+1. 配置TeXstudio。
+
+ 启动Texstudio,选择 `Options-->Configure Texstudio-->Commands`,XeLaTex 设置为 `xelatex -synctex=1 -interaction=nonstopmode %.tex`;
+
+ 选择 `Options-->Configure Texstudio-->Build`
+
+ Build & View 由默认的 PDF Chain 改为 Compile & View;
+
+ Default Compiler 由默认的PdfLaTex 修改为 XeLaTex ;
+
+ PDF Viewer 改为 “Internal PDF Viewer(windowed)”,这样预览时会弹出一个独立的窗口,这样比较方便。
+
+1. 编译。用TeXstudio打开`ACM-cheat-sheet.tex`,点击界面上的绿色箭头就可以开始编译了。
+
+ 在下方的窗口可以看到TeXstudio正在使用的编译命令是`xelatex -synctex=1 -interaction=nonstopmode "ACM-cheat-sheet".tex`
+
+## 在Ubuntu下编译
+1. 安装Tex Live 2016
+
+ 1.1. 下载TexLive 2016 的ISO 光盘,地址
+
+ 1.2 mount 光盘,`sudo ./install-tl` 开始安装
+
+ 1.3 加入环境变量
+
+ sudo vi /etc/profile
+ export PATH=$PATH:/usr/local/texlive/2016/bin/x86_64-linux
+ export MANPATH=$MANPATH:/usr/local/texlive/2016/texmf-dist/doc/man
+ export INFPATH=$INFPATH:/usr/local/texlive/2016/texmf-dist/doc/info
+
+1. 安装字体。这个LaTex模板总共使用了9个字体,下载地址 ,有的字体Windows自带了,有的字体Ubuntu自带了,但都不全,还是一次性安装完所有字体比较方便。
+1. 安装TeXstudio
+1. 配置TeXstudio。
+
+ 启动Texstudio,选择 `Options-->Configure Texstudio-->Commands`,XeLaTex 设置为 `xelatex -synctex=1 -interaction=nonstopmode %.tex`;
+
+ 选择 `Options-->Configure Texstudio-->Build`
+
+ Build & View 由默认的 PDF Chain 改为 Compile & View;
+
+ Default Compiler 由默认的PdfLaTex 修改为 XeLaTex ;
+
+ PDF Viewer 改为 “Internal PDF Viewer(windowed)”,这样预览时会弹出一个独立的窗口,这样比较方便。
+
+1. 编译。用TeXstudio打开`ACM-cheat-sheet.tex`,点击界面上的绿色箭头就可以开始编译了。
+
+ 在下方的窗口可以看到TeXstudio正在使用的编译命令是`xelatex -synctex=1 -interaction=nonstopmode "ACM-cheat-sheet".tex`
+1. 懒人版镜像。如果不想进行上面繁琐的安装过程,我做好了一个Ubuntu VMware虚拟机镜像,已经装好了TexLive 2016, TexStudio和字体(详细的安装日志见压缩包注释),开箱即用,下载地址 。
+
+## 如何贡献代码
+编译通过后,就具备了完整的LaTeX编译环境了。
+
+本书模板已经写好了,基本上不需要很多LaTeX知识就可以动手了。
+
+欢迎给本书添加内容或纠正错误,在自己本地编译成PDF,预览没问题后,就可以发pull request过来了。
+
+
+## 小密圈
+
+![](参考资料/silicon-job.jpeg)
diff --git a/new.txt b/new.txt
new file mode 100644
index 0000000..9dd04cd
--- /dev/null
+++ b/new.txt
@@ -0,0 +1 @@
+lifadfliguifan
diff --git a/new2.txt b/new2.txt
new file mode 100644
index 0000000..fa2be78
--- /dev/null
+++ b/new2.txt
@@ -0,0 +1 @@
+liguifan
diff --git "a/\345\217\202\350\200\203\350\265\204\346\226\231/silicon-job.jpeg" "b/\345\217\202\350\200\203\350\265\204\346\226\231/silicon-job.jpeg"
index 58dca6b..171bf32 100644
Binary files "a/\345\217\202\350\200\203\350\265\204\346\226\231/silicon-job.jpeg" and "b/\345\217\202\350\200\203\350\265\204\346\226\231/silicon-job.jpeg" differ
diff --git "a/\345\217\202\350\200\203\350\265\204\346\226\231/\350\203\214\345\214\205\351\227\256\351\242\230\344\271\235\350\256\262.html" "b/\345\217\202\350\200\203\350\265\204\346\226\231/\350\203\214\345\214\205\351\227\256\351\242\230\344\271\235\350\256\262.html"
new file mode 100644
index 0000000..144296a
--- /dev/null
+++ "b/\345\217\202\350\200\203\350\265\204\346\226\231/\350\203\214\345\214\205\351\227\256\351\242\230\344\271\235\350\256\262.html"
@@ -0,0 +1,180 @@
+
+version 1.1 build 20071115
+
+前言
+目录
+第一讲 01背包问题
+第二讲 完全背包问题
+第三讲 多重背包问题
+第四讲 混合三种背包问题
+第五讲 二维费用的背包问题
+第六讲 分组的背包问题
+第七讲 有依赖的背包问题
+第八讲 泛化物品
+第九讲 背包问题问法的变化
+附录一:USACO中的背包问题
+附录二:背包问题的搜索解法
+联系方式
+致谢
+前言
+本篇文章是我(dd_engi)正在进行中的一个雄心勃勃的写作计划的一部分,这个计划的内容是写作一份较为完善的NOIP难度的动态规划总结,名为《解动态规划题的基本思考方式》。现在你看到的是这个写作计划最先发布的一部分。
+
+背包问题是一个经典的动态规划模型。它既简单形象容易理解,又在某种程度上能够揭示动态规划的本质,故不少教材都把它作为动态规划部分的第一道例题,我也将它放在我的写作计划的第一部分。
+
+读本文最重要的是思考。因为我的语言和写作方式向来不以易于理解为长,思路也偶有跳跃的地方,后面更有需要大量思考才能理解的比较抽象的内容。更重要的是:不大量思考,绝对不可能学好动态规划这一信息学奥赛中最精致的部分。
+
+你现在看到的是本文的v1.1版,发布于2007年11月15日。我会长期维护这份文本,把大家的意见和建议融入其中,也会不断加入我在OI学习以及将来可能的ACM-ICPC的征程中得到的新的心得。但目前本文还没有一个固定的发布页面,想了解本文是否有更新版本发布,可以在OIBH论坛中以“背包问题九讲”为关键字搜索贴子,每次比较重大的版本更新都会在这个论坛里发贴公布。也可以用“背包问题九讲”为关键字在搜索引擎中搜索以得到最新版本。
+
+目录
+第一讲 01背包问题
+这是最基本的背包问题,每个物品最多只能放一次。
+
+第二讲 完全背包问题
+第二个基本的背包问题模型,每种物品可以放无限多次。
+
+第三讲 多重背包问题
+每种物品有一个固定的次数上限。
+
+第四讲 混合三种背包问题
+将前面三种简单的问题叠加成较复杂的问题。
+
+第五讲 二维费用的背包问题
+一个简单的常见扩展。
+
+第六讲 分组的背包问题
+一种题目类型,也是一个有用的模型。后两节的基础。
+
+第七讲 有依赖的背包问题
+另一种给物品的选取加上限制的方法。
+
+第八讲 泛化物品
+我自己关于背包问题的思考成果,有一点抽象。
+
+第九讲 背包问题问法的变化
+试图触类旁通、举一反三。
+
+附录一:USACO中的背包问题
+给出 USACO Training 上可供练习的背包问题列表,及简单的解答。
+
+附录二:背包问题的搜索解法
+除动态规划外另一种背包问题的解法。
+
+联系方式
+如果有任何意见和建议,特别是文章的错误和不足,或者希望为文章添加新的材料,可以通过http://kontactr.com/user/tianyi/这个网页联系我。
+
+值得说明的是,如果有OI方面的问题,例如不明白自己的程序为什么错了或者索要某种算法的源代码,使用这个联系方式可能得不到及时解答。请在OIBH论坛发问。
+
+致谢
+感谢以下名单:
+
+阿坦
+jason911
+donglixp
+LeafDuo
+他们每人都最先指出了本文曾经存在的某个并非无关紧要的错误。谢谢你们如此仔细地阅读拙作并弥补我的疏漏。
+
+感谢 XiaQ,它针对本文的第一个beta版发表了用词严厉的六条建议,虽然我只认同并采纳了其中的两条。在所有读者几乎一边倒的赞扬将我包围的当时,你的贴子是我的一剂清醒剂,让我能清醒起来并用更严厉的眼光审视自己的作品。
+
+sfita 提供了P01中的“一个常数优化”。
+
+当然,还有用各种方式对我表示鼓励和支持的几乎无法计数的同学。不管是当面赞扬,或是在论坛上回复我的贴子,不管是发来热情洋溢的邮件,或是在即时聊天的窗口里竖起大拇指,你们的鼓励和支持是支撑我的写作计划的强大动力,也鞭策着我不断提高自身水平,谢谢你们!
+
+最后,感谢 Emacs 这一世界最强大的编辑器的所有贡献者,感谢它的插件 EmacsMuse 的开发者们,本文的所有编辑工作都借助这两个卓越的自由软件完成。谢谢你们——自由软件社群——为社会提供了如此有生产力的工具。我深深钦佩你们身上体现出的自由软件的精神,没有你们的感召,我不能完成本文。在你们的影响下,采用自由文档的方式发布本文档,也是我对自由社会事业的微薄努力。
+
+首页
+
+Copyright (c) 2007 Tianyi Cui
+
+Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
+
+背包问题九讲
+
+version 1.1 build 20071115
+
+前言
+目录
+第一讲 01背包问题
+第二讲 完全背包问题
+第三讲 多重背包问题
+第四讲 混合三种背包问题
+第五讲 二维费用的背包问题
+第六讲 分组的背包问题
+第七讲 有依赖的背包问题
+第八讲 泛化物品
+第九讲 背包问题问法的变化
+附录一:USACO中的背包问题
+附录二:背包问题的搜索解法
+联系方式
+致谢
+前言
+本篇文章是我(dd_engi)正在进行中的一个雄心勃勃的写作计划的一部分,这个计划的内容是写作一份较为完善的NOIP难度的动态规划总结,名为《解动态规划题的基本思考方式》。现在你看到的是这个写作计划最先发布的一部分。
+
+背包问题是一个经典的动态规划模型。它既简单形象容易理解,又在某种程度上能够揭示动态规划的本质,故不少教材都把它作为动态规划部分的第一道例题,我也将它放在我的写作计划的第一部分。
+
+读本文最重要的是思考。因为我的语言和写作方式向来不以易于理解为长,思路也偶有跳跃的地方,后面更有需要大量思考才能理解的比较抽象的内容。更重要的是:不大量思考,绝对不可能学好动态规划这一信息学奥赛中最精致的部分。
+
+你现在看到的是本文的v1.1版,发布于2007年11月15日。我会长期维护这份文本,把大家的意见和建议融入其中,也会不断加入我在OI学习以及将来可能的ACM-ICPC的征程中得到的新的心得。但目前本文还没有一个固定的发布页面,想了解本文是否有更新版本发布,可以在OIBH论坛中以“背包问题九讲”为关键字搜索贴子,每次比较重大的版本更新都会在这个论坛里发贴公布。也可以用“背包问题九讲”为关键字在搜索引擎中搜索以得到最新版本。
+
+目录
+第一讲 01背包问题
+这是最基本的背包问题,每个物品最多只能放一次。
+
+第二讲 完全背包问题
+第二个基本的背包问题模型,每种物品可以放无限多次。
+
+第三讲 多重背包问题
+每种物品有一个固定的次数上限。
+
+第四讲 混合三种背包问题
+将前面三种简单的问题叠加成较复杂的问题。
+
+第五讲 二维费用的背包问题
+一个简单的常见扩展。
+
+第六讲 分组的背包问题
+一种题目类型,也是一个有用的模型。后两节的基础。
+
+第七讲 有依赖的背包问题
+另一种给物品的选取加上限制的方法。
+
+第八讲 泛化物品
+我自己关于背包问题的思考成果,有一点抽象。
+
+第九讲 背包问题问法的变化
+试图触类旁通、举一反三。
+
+附录一:USACO中的背包问题
+给出 USACO Training 上可供练习的背包问题列表,及简单的解答。
+
+附录二:背包问题的搜索解法
+除动态规划外另一种背包问题的解法。
+
+联系方式
+如果有任何意见和建议,特别是文章的错误和不足,或者希望为文章添加新的材料,可以通过http://kontactr.com/user/tianyi/这个网页联系我。
+
+值得说明的是,如果有OI方面的问题,例如不明白自己的程序为什么错了或者索要某种算法的源代码,使用这个联系方式可能得不到及时解答。请在OIBH论坛发问。
+
+致谢
+感谢以下名单:
+
+阿坦
+jason911
+donglixp
+LeafDuo
+他们每人都最先指出了本文曾经存在的某个并非无关紧要的错误。谢谢你们如此仔细地阅读拙作并弥补我的疏漏。
+
+感谢 XiaQ,它针对本文的第一个beta版发表了用词严厉的六条建议,虽然我只认同并采纳了其中的两条。在所有读者几乎一边倒的赞扬将我包围的当时,你的贴子是我的一剂清醒剂,让我能清醒起来并用更严厉的眼光审视自己的作品。
+
+sfita 提供了P01中的“一个常数优化”。
+
+当然,还有用各种方式对我表示鼓励和支持的几乎无法计数的同学。不管是当面赞扬,或是在论坛上回复我的贴子,不管是发来热情洋溢的邮件,或是在即时聊天的窗口里竖起大拇指,你们的鼓励和支持是支撑我的写作计划的强大动力,也鞭策着我不断提高自身水平,谢谢你们!
+
+最后,感谢 Emacs 这一世界最强大的编辑器的所有贡献者,感谢它的插件 EmacsMuse 的开发者们,本文的所有编辑工作都借助这两个卓越的自由软件完成。谢谢你们——自由软件社群——为社会提供了如此有生产力的工具。我深深钦佩你们身上体现出的自由软件的精神,没有你们的感召,我不能完成本文。在你们的影响下,采用自由文档的方式发布本文档,也是我对自由社会事业的微薄努力。
+
+首页
+
+Copyright (c) 2007 Tianyi Cui
+
+Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
+
+>
\ No newline at end of file