Time Limit: 1000MS Memory Limit: 65535KBTotal Submissions: 143 Accepted: 28 Description:One of the fundamental problems of computer science is ordering a list of items. There're a plethora of solutions to this problem ,known as sorting
為了記錄搜尋的軌跡,廣度優先搜尋將每個頂點都找色為白色、灰色和黑色。演算法開始時,所有的頂點都是白色的。伴隨著搜尋的進行,各頂點會逐漸層成灰色,然後成為黑色。與黑色頂點相鄰的所有定點都是已經被發現的。灰色頂點可能會有一些白色的相鄰頂點,他們代表了已發現與未發現頂點之間的邊界。對於每一個頂點u,其色彩儲存於變數color[u]中,u的父母存於變數pai[u]中。具體代碼如下所示(python實現)def GFS(G, s): print s color = {} d = {}
Time Limit: 7000MS Memory Limit: 65536KBTotal Submissions: 20 Accepted: 7 Description:In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence
剛剛寫了圖的廣度優先演算法,現在完成深度優先演算法DFS,color等的意義和上一篇一致,但f用於記錄完成時間。DFScolor = {}pai = {}d = {}time = 0f = {} # 記錄完成時間def DFS(G): for u in G.keys(): color[u] = 'WHITE' pai[u] = 'NIL' time = 0 for u in G.keys(): if color[u] ==
看了論文《Deeply Exploiting Link Structure: Setting a Tougher Life for Spammers》,用Java和webgraph庫實現了一下其中的演算法CPV,即計算AVRank和HVRank。最終的結果沒有做歸一化處理,我用資料集試了一下,發現效果還不錯。代碼實現如下:package cn.edu.dlut.wisdom;import it.unimi.dsi.webgraph.*;public class Cpv { private
deb http://Ubuntu.uestc.edu.cn/ubuntu/ karmic main restricted universe multiversedeb http://Ubuntu.uestc.edu.cn/ubuntu/ karmic-backports main restricted universe multiversedeb http://Ubuntu.uestc.edu.cn/ubuntu/ karmic-proposed main restricted