原创 SDOI 2013 直徑

可以去洛谷看我的題解 #include<bits/stdc++.h> using namespace std; const int maxn = 200010; int n, tot, far; long long maxd; i

原创 NOIP 2016 Day2 T3 憤怒的小鳥

//狀壓DP,(1<<n)-1相當於全集。 #include<bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const double lit =

原创 洛谷 1875 佳佳的魔法藥水

//此題像遊戲裏的裝備合成樹。類似於樹形結構,但又存在環。所以不能用樹形DP,考慮貪心的思想,每次用一個當前最小代價得到藥水(一定是當前最優價格)+已經確定藥水價格的藥水來合成另一個藥水,更新他的價格,這就是Dijkstra的思想

原创 洛谷 1908 逆序對

//樹狀數組 #include<bits/stdc++.h> using namespace std; const int maxn = 100010; int n, s, haoyu[maxn], c[maxn]; stru

原创 NOI 2015 程序自動分析

//要先處理=再判斷!= //離散化後並的是地址而非數值 //low_bound可查詢特定數值所在的地址,和map差不多? //思考查找其他離散化的方法 #include<bits/stdc++.h> using names

原创 SDSC 2017 Day1 T2 && 洛谷 2652 同花順

#include<bits/stdc++.h> using namespace std; int ans, tot, n; struct node{ int c, r; } a[100010], b[100010];

原创 洛谷 1073 最優貿易

//反BFS找能到終點的點,正BFS找到此點及以前最小代價。正BFS實際上是SPFA,要熟練掌握重複更新的思想。 #include<bits/stdc++.h> using namespace std; const int max

原创 洛谷 1196 銀河英雄傳說

#include<bits/stdc++.h> using namespace std; const int maxn = 30030; int t, fa[maxn], siz[maxn], dis[maxn]; inline

原创 Hash中的base與moder的建議

base = 163 moder = 9905411 || 1e9+7

原创 洛谷 1168 中位數

#include<bits/stdc++.h> using namespace std; int n, sum1, sum2; priority_queue<int, vector<int>, greater<int> > q2;

原创 洛谷3372 線段樹1

//注意求和要*區間個數 #include<bits/stdc++.h> using namespace std; const int maxn = 100010; int n, m; long long a[maxn]; st

原创 HOJ 2662 Pieces Assignment

新學狀態壓縮DP。 http://www.cnblogs.com/avril/p/3282295.html #include<bits/stdc++.h> #define LL long long using namespace

原创 [字符串專項] Manacher算法

Manacher算法 算法過程分析 參考資料 https://subetter.com/algorithm/manacher-algorithm.html 由於迴文分爲偶迴文(比如 bccb)和奇迴文(比如 bcacb),而在處理奇

原创 [字符串專項] 基本IO及函數

基礎IO cin & scanf 讀入以’\n’或’ '作爲分割符. getline getline(cin, str); 具體情境 讀入帶空格字符串用gets(). 讀入不帶空格字符串用scanf, cin.

原创 [字符串專項] 字符串Hash

單哈希 洛谷 3370 #include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; typed