MysteryTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 141 Accepted Submission(s): 75 InputThe first line of input contains a single integer P, (1 <= P <= 1000), which is the number
第一道LCA Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include<stdio.h>#include<string.h>#define N 10001int unionset[N],visit[N];int main(){int T,n,a,b,i; scanf("%d",&T);while(T--
首先看我對kmp解決周期、首碼與尾碼間關係的解釋http://www.cnblogs.com/wuyiqi/archive/2012/01/06/2314078.htmlhdu 3336 count the string題意:求給定字串含首碼的數量abab首碼為aababaabababab中共有六個子串是首碼a a ab ab aba abab所以答案為6利用kmp中的匹配原理可以完美的解決此題 a---------d----- -----a---------d
Gao the GridTime Limit: 2 Seconds Memory Limit: 65536 KBA n * m grid as follow: Count the number of triangles, three of whose vertice must be grid-points.Note that the three vertice of the triangle must not be in a line(the right picture is not
這題也是赤裸裸的最大二分匹配。在最後加個判斷即可。 注意,用cin會逾時,要用scanf #include<iostream>using namespace std;const int MAX = 305;bool arcs[MAX][MAX];bool isvisit[MAX];int match[MAX];int n, m;bool find(int u){for (int i = 1; i <= m; i++)if (arcs[u][i]
因為題目告訴我們每兩點間只有一條路相連 that there is exactly one path between any two free blocks. 就可以把點之間形成的路徑看成是一棵樹題目又要我們找最長的一條路,瞬間就可以轉換成樹的最長路來做了結論是從樹上的任何一點出發,能搜到的最遠的點肯定是最長鏈上的一端,再從這一端出發,能搜到的最遠的點的距離即為答案證明過程詳見View Code