51 nod 1521 一維戰艦 時間複雜度O(n),同 Codeforces 567D. One-Dimensional Battle Ships 有詳細註釋

題目:51nod: 題目Codeforces:       題目注意到兩個戰艦不能挨在一起就可以了。   // 每一段 struct node{ int left; // 段的左端點 int right; // 段的右端點 int length; // 段長度 int ship; // 段最大容納戰艦數 }arr[200005]; 每一段可容納戰艦數: sh
相關文章
相關標籤/搜索