原创 【洛谷】P3717 [AHOI2017初中組]cover 【python】

【洛谷】P3717 [AHOI2017初中組]cover 【python】 1.題意 2.分析 3.代碼 import math # 引入數學計算的包 N=105 arr = [[0 for i in range(N)] for

原创 git報錯 Error saving your changes: Description control characters are not allowed

git報錯 Error saving your changes: Description control characters are not allowed 1.報錯內容 在git中給項目添加描述時,有時會遇到下面這種錯誤: E

原创 【洛谷】P1789 【Mc生存】插火把 【python】

【洛谷】P1789 【Mc生存】插火把 【python】 1.題意 2.分析 3.代碼 # 讀數據到數組中 def readToArray(): s = input() nums = s.strip().split

原创 【洛谷】P1116 車廂重組【python版】

【洛谷】P1116 車廂重組【python】 0.題意 本題目寫成入門的紅題總感覺有些不妥,至少是普及的級別了吧。徒手寫歸併也不是2min就能搞定的。 1.分析 用歸併排序求逆序數 本題主要有如下幾個點需要注意: 01.歸併排序用

原创 【洛谷】P1830 轟炸III 【python版】

【洛谷】P1830 轟炸III 【python版】 1.題意 略 2.分析 直接模擬 使用python 申請一個二維數組【使用生成表達式】 3.代碼 s = input() nums = s.strip().split()

原创 快速排序逐行代碼精析

快速排序逐行代碼精析 1.定義 快速排序有三要素: 分區算法【如何將一個無序的數組分區,纔是快速排序的關鍵】 遞歸【分治法解決問題】 合併問題【其實不用合併數組,因爲數組在遞歸的時候就已經完全有序了】 2.算法思想 利用分治

原创 【洛谷】P1107 [BJWC2008]雷濤的小貓

【洛谷】P1107 [BJWC2008]雷濤的小貓 1.題意 給出若干棵樹,以及每棵樹不同高度有幾個柿子的信息。以及給出走法規則,求能夠獲取到最多的柿子數。 2.分析 線形dp題 問題抽象轉換 2.1 方法1 我自己的方法是:

原创 【洛谷】P1122 最大子樹和

【洛谷】P1122 最大子樹和 0.總結 Get to the points firstly, the article comes from LawsonAbs! 樹型dp 1.題意 這應該是經典的一道dp題。 言下之意就

原创 【洛谷】 P3879 [TJOI2010]閱讀理解

【洛谷】 P3879 [TJOI2010]閱讀理解 0.總結 Get to the points first. The article comes from LawsonAbs! trie樹 二維數組隱式越界坑 1.題意

原创 【洛谷】P2580 於是他錯誤的點名開始了

【洛谷】P2580 於是他錯誤的點名開始了 0.總結 Get to the points firstly, the article comes from LawsonAbs! trie 樹 字符串處理 1.trie 樹 在

原创 【算法競賽bug經驗談】編程經驗總結【C/C++】

【算法競賽bug經驗談】編程經驗總結【C/C++】 0.總結 Get to the points first. The article comes from LawsonAbs! 記錄我自己編寫算法題時犯過的錯誤 1.踩過

原创 【洛谷】P1137 旅行計劃

【洛谷】P1137 旅行計劃 0.總結 Get to the points first. The article comes from LawsonAbs! 樹形dp問題的處理 拓撲排序 1.題意 其實就是求一棵樹裏各個節

原创 【算法競賽刷題模板9】拓撲排序

【算法競賽刷題模板9】拓撲排序 0、總結 Get to the points firstly, the article comes from LawsonAbs! 基於隊列實現拓撲排序; 如何判斷拓撲排序不唯一? 如何對拓撲排

原创 【算法競賽模板1】結構體排序

【算法競賽模板1】結構體排序 0.總結 Get to the points firstly, the article comes from LawsonAbs! 實現對結構體的排序 1.代碼 1.1主要代碼 定義一個結構

原创 【算法競賽刷題模板10】基於倍增算法求LCA

【算法競賽刷題模板10】基於倍增算法求LCA 0.總結 Get to the points first. The article comes from LawsonAbs! 二進制拆分 LCA的樹上倍增算法實現 1.問題