原创 每日一題 3月30日 滑動窗口 單調隊列

題目鏈接:https://ac.nowcoder.com/acm/problem/50528 //單調隊列的模板題。 #include <bits/stdc++.h> using namespace std; int a[1

原创 牛客練習賽60 C-操作集錦 長度爲k的子序列個數(DP)

題目鏈接:https://ac.nowcoder.com/acm/contest/4853/C #include <bits/stdc++.h> using namespace std; #define LL long lon

原创 POJ 1390 Blocks - 顏色段消除的最大分數 三維DP

題目鏈接:http://poj.org/problem?id=1390&tdsourcetag=s_pctim_aiomsg 題目大意:一個積木遊戲,有連續的n個方塊。相同顏色的方塊連續方塊可以消除。如果該段由k個積木組成。得分爲

原创 每日一題 4月1日 Rinne Loves Edges 樹形DP

題目鏈接:https://ac.nowcoder.com/acm/problem/22598?&headNav=acm #include<bits/stdc++.h> #define LL long long using n

原创 區間的連續段 - 倍增DP

題目鏈接:https://ac.nowcoder.com/acm/contest/82/B #include<bits/stdc++.h> #define LL long long using namespace std;

原创 每日一題 3月26日 合併迴文子串 區間DP

題目鏈接:https://ac.nowcoder.com/acm/problem/13230 思路:我們用f[l1][r1][l2][r2]:表示A[l1]A[r1]和B[l2]B[r2]是否能合併成一個迴文串。 考慮轉移:因爲

原创 洛谷P3147 DP-倍增

題目鏈接:https://www.luogu.com.cn/problem/P3147 題目大意: 思路: 我們用f[i][j]表示從位置j開始合並成一個數i的最遠位置。怎麼轉移呢?我們只考慮i由兩個i−1合並而來。那麼合並完第

原创 每日一題 3月25日 tokitsukaze and Soldier 優先隊列

題目鏈接:https://ac.nowcoder.com/acm/problem/50439 思路:思路:我們考慮按s[i]存入vectoc,從大到小枚舉s[i]的值。那麼就是在所有>=s[i]的士兵中選v最大的s[i]個。我們

原创 Codeforces Round #622 (Div. 2) C2. Skyscrapers (hard version)-單調棧+dp

題目鏈接:https://codeforces.ml/contest/1313/problem/C2 題目大意: 有n棟房子。每個房子的最高的高度b[i]應該在[1, a[i]]區間裏。現在要滿足不存在i<j<k有a[i]>a[j

原创 牛客小白月賽22 H 貨物種類- 掃描線+差分

題目鏈接:https://ac.nowcoder.com/acm/contest/4462/H 題目大意: 思路:我們可以把每個倉庫當作一個時間點。把操作顏色離線保存。 那麼對於一個操作就是拆分:在時間點l添加顏色d。在r去掉顏色

原创 牛客練習賽60 D-斬殺線計算大師(exgcd)

思路: #include <bits/stdc++.h> using namespace std; #define ll long long ll extend_gcd(ll a,ll b,ll&x,ll&y) {

原创 博客搬家-新地址

新地址:https://blog.nowcoder.net/liweihang

原创 學軍信友隊趣味網絡邀請賽 A-B-D 思維+樹形DP/直徑+數論

題目鏈接:http://115.236.49.52:83/contest/1351 題解:假設n是奇數。n如果是偶數,翻轉90度就可以了。 B: #include <bits/stdc++.h> using names

原创 每日一題 4月7日 樹 dfs序+DP

題目鏈接:https://ac.nowcoder.com/acm/problem/13611 #include <bits/stdc++.h> #define LL long long using namespace std;

原创 牛客OI周賽15-提高組 - 恢復數列

題目鏈接:https://ac.nowcoder.com/acm/contest/4912/B #include <bits/stdc++.h> #define LL long long using namespace std