原创 2019hdu暑假多校訓練營第四場 H 主席樹+二分

主席樹+二分 二分與p的距離,確定與[p-mid,p+mid]這個區間中有多少個點,如果大於等於k個,說明這個區間合理,可以縮小尋找範圍,否則增大尋找範圍。 #include<bits/stdc++.h> using namespace

原创 2019 牛客暑假多校訓練營 第四場 I 廣義後綴自動機+迴文自動機

 廣義後綴自動機,求多個串的本質不同子串個數。 迴文自動機求迴文串個數 #include<bits/stdc++.h> using namespace std; const int maxn = 4e5+100; char s[maxn

原创 2019瀋陽網絡賽B 並查集+dfs

補題的時候,忘記將怪獸節點的size值變爲0。 #include<bits/stdc++.h> using namespace std; int fa[200005],siz[200005]; int getfa(int x) {

原创 牛客網小白月賽 16 H 線段樹求gcd

線段樹維護差分數組,求gcd #include<bits/stdc++.h> using namespace std; const int maxn=1e5+100; int sum[maxn*4]; int gcd[maxn*4],m

原创 掃描線求矩形是否相交

#include<bits/stdc++.h> using namespace std; const int maxn=300005; struct node { int l,r,h,val; bool operator

原创 牛客網小白月賽 16 H

線段樹維護查分數組,求gcd #include<bits/stdc++.h> using namespace std; const int maxn=1e5+100; int sum[maxn*4]; int gcd[maxn*4],m

原创 2019hdu暑假多校訓練營第四場 H

主席樹+二分 二分與p的距離,確定與[p-mid,p+mid]這個區間中有多少個點,如果大於等於k個,說明這個區間合理,可以縮小尋找範圍,否則增大尋找範圍。 #include<bits/stdc++.h> using namespace

原创 洛谷p2444 p4052 AC自動機

ac自動機fail指針,即爲當失配後,跳轉至與當前後綴相同的一個前綴上。 因此如果一個點的fail指向的點是一個單詞的終止,那麼說明當前匹配到的這個位置,一定包括這個單詞。 因此建立fail指針時,我們可以更新ed的值,由此來判斷,當到達

原创 hdu多校2 I I Love Palindrome String 迴文自動機+hash

迴文自動機學習鏈接:https://blog.csdn.net/lwfcgz/article/details/48739051                                       https://www.cnblo

原创 洛谷p2322 ac自動機+最短路+dfs

ac自動機建立fail指針,求出每個點能覆蓋的全部串種類,bfs求出最短母串長度(最短路),dfs求出路徑輸出。 #include <iostream> #include <stdio.h> #include <stdlib.h> #i

原创 hdu 5068&&2019牛客網暑假多校訓練賽E 線段樹+矩陣乘法

hdu 2068  #include<bits/stdc++.h> using namespace std; //用線段樹維護一個2*2的矩陣,a[i][j]表示從這一層第i個門到下一層第j個門是否聯通, //第i層到第j層之間的矩陣相

原创 hdu6333 莫隊+組合數

#include<bits/stdc++.h> using namespace std; //組合數性質: //(n,m)=(n-1,m-1)+(n-1,m); //由題意可知求s(n,m)=sega(i=0-m)(n,i); //s(

原创 求最大1矩陣(單調棧)

#include<iostream> #include<string> #include<algorithm> #include<cstdlib> #include<cstdio> #include<set> #include<map>

原创 主席樹學習總結

主席樹即每次建立改變點的鏈接,建立n顆權值線段樹,根據其類似於前綴和的性質,求解區間第k大問題。 POJ - 2104 數組區間上求第k大: #include<iostream> #include<string> #include<al

原创 基礎莫隊分塊優化模板

#include<bits/stdc++.h> using namespace std; //分塊時按左端點所在塊排序,塊內按照右端點排序 const int maxn=100000; struct query { int l,