原创 河南省第十一屆ACM大學生程序設計競賽 部分題解

題目鏈接 A 計劃日 #include <stdio.h> #include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF =

原创 Codeforces Round #552 (Div. 3) 題解

題目鏈接 A. Restoring Three Numbers #include <stdio.h> #include <bits/stdc++.h> #define fst first #define sed second us

原创 河南省第九屆ACM程序設計競賽 部分題解

題目鏈接 A 表達式求值 <逆波蘭> #include <stdio.h> #include <bits/stdc++.h> #define fst first #define sed second using namespace

原创 “卓見杯”第五屆CCPC中國大學生程序設計競賽河南省賽 題解

題目鏈接 A 最大下降矩陣 <dp> 最長上升子序列的變形。 令f[i]表示以i爲結尾的最長非遞減子序列長度,每次轉移遍歷一整排數字,如果都滿足再進行轉移。 #include <stdio.h> #include <bits/st

原创 2020牛客寒假算法基礎集訓營3 題目解析及知識點整理

這裏引用一下官方題解 A. 牛牛的DRB迷宮I 考察點:動態規劃 可以使用暴力搜索來獲取所有的方案數,但是如同斐波那契數列一樣,數據一大就不能計算,因爲我們重複算了很多次相同的內容. 改用遞推法求解,設d[i][j]爲從(1,

原创 Codeforces Round #552 (Div. 3)

題目鏈接 A. Restoring Three Numbers #include <stdio.h> #include <bits/stdc++.h> #define fst first #define sed second usin

原创 小P的祕籍 ZZULIOJ - 1523 二分 ST表

題解 類似於括號匹配,將K看爲1將A看爲-1做前綴和記爲a。如果某個區間[l, r]合法則a[l - 1]爲當前區間內的a的最小值、a[r]爲區間內的a最大值。 使用單調棧求出兩個數組l、r,l表示當前位置向左第一個大於當前a的位置、

原创 Farm Tour POJ - 2135 費用流

題解 要求從起點到終點在回到起點,可以看做起點到終點流量爲2的網絡流。題目所給出的邊沒有方向設置爲兩條容量爲1的有向邊。 限制流大小爲2,最後跑最小費用最大流即可。 AC代碼 #include <stdio.h> #include <

原创 Flow Problem HDU - 3549 最大流

題解 模板題。。dinic求最大流。 AC代碼 #include <stdio.h> #include <bits/stdc++.h> #define fst first #define sed second using namesp

原创 ACM-ICPC 2018 南京區域賽 D. Country Meow 三分 | 模擬退火

題解 題目大意給n個三維座標系的點,要求找到一個點到達這些點的最遠距離最近。 三分法: 因爲答案函數單峯且三個維度的最優解相互獨立,所以使用三次三分嵌套求出最優的x、y、z。 模擬退火: 玄學算法。。隨機選取一個點檢測是否更優然後更新

原创 “卓見杯”第五屆CCPC中國大學生程序設計競賽河南省賽-網絡模擬賽 部分題解

題目鏈接 A Mex Query #include <stdio.h> #include <bits/stdc++.h> #define fst first #define sed second using namespace std

原创 鄭州輕工業大學“CCPC2019-河南省賽”選拔賽(2) 部分題解

題目鏈接 A 火柴棒等式 <暴力> #include <stdio.h> #include <bits/stdc++.h> #define fst first #define sed second using namespace st

原创 “卓見杯”第五屆CCPC中國大學生程序設計競賽河南省賽 部分題解

A 最大下降矩陣 < dp > 最長上升子序列的變形。 令f[i]表示以i爲結尾的最長非遞減子序列長度,每次轉移遍歷一整排數字,如果都滿足再進行轉移。 #include <stdio.h> #include <bits/stdc++.

原创 2018年北京信息科技大學第十屆程序設計競賽暨ACM選拔賽

A PUBG <dijkstra> 邊權不爲1時最短路使用dijkstra。 #include <stdio.h> #include <bits/stdc++.h> #define fst first #define sed seco

原创 Codeforces Global Round 2

A. Ilya and a Colorful Walk #include <stdio.h> #include <bits/stdc++.h> #define fst first #define sed second using na