Time Limit : 10000/5000ms (Java/Other) Memory Limit : 102400/204800K (Java/Other)Total Submission(s) : 23 Accepted Submission(s) : 12Problem DescriptionIgnatius is so lucky that he met a Martian yesterday. But he didn't know the language the
Problem Description We all use cell phone today. And we must be familiar with the intelligent English input method on the cell phone. To be specific, the number buttons may correspond to some English letters respectively, as shown below: 2 : a, b,
題目來源http://218.194.91.48/acmhome/problemdetail.do?&method=showdetail&id=1456描述 Bruce Force's keyboard is broken, only a few keys are still working. Bruce has figured out he can still type texts by switching the keyboard layout whenever he
給出一張無向圖,求一個最小環並輸出路徑。說說我的感覺:包含點 i 和點 j 的最小環,我們可以看成是 i 到 j 之間的最短路和次短路的組合,通過 floyd 可求任意兩點之間的最短距離,那麼我們只要找到最短路徑外的一條最短路來保證 i 和 j 之間可達即可。在做 floyd 迴圈的同時,我們以 環權值 最小(最短路權值+次短路權值=最小環權值)為標準,一直更新每個點的前驅,也就是記錄 i 到 j 的最短路徑,以及,能夠鬆弛 i 和 j 的點 k (k 不在 i 到 j
Problem DescriptionFatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p < n and 0 <= q < n. At each grid location Fatmouse has hid
LCA(最近公用祖先)的離線演算法,用到的是 tarjan 的思想,並用並查集標記父親節點。說說我的理解:我們從根開始深搜遍曆樹,每當回溯到一個節點時,那就意味著我們已經完成了該節點子樹的遍曆,顯然這個節點就是子樹中點以及其本身的最近公用祖先,以此類推到整個樹。這裡非常巧妙的一點是,對於一個點,只有完成了其子樹的遍曆,我們才改變其 父節點 的值(賦初值為father[ i ] = i),這樣,對於每次詢問(就是給出兩點標號,要求求出兩點間最短距離,算一次詢問。假設為 A 和 B),我們搜到 A