ACM SCL
文章平均质量分 56
vocaloid01
小菜鸟一只_(:з」∠)_前来膜拜各路大佬orz
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
SG函数
Sprague-Grundy定理(SG定理):游戏和的SG函数等于各个游戏SG函数的Nim和。这样就可以将每一个子游戏分而治之,从而简化了问题。而Bouton定理就是Sprague-Grundy定理在Nim游戏中的直接应用,因为单堆的Nim游戏 SG函数满足 SG(x) = x。SG函数:首先定义mex(minimal excludant)运算,这是施加于一个集合的运算,表示最小的不属...原创 2018-08-15 10:56:14 · 279 阅读 · 0 评论 -
基础字典树模板
char s[MAXN];typedef struct Node* node;struct Node{ int Num;//常见的是存数,具体的根据题更改 node Next[26]; Node() { Num = 0; memset(Next,NULL,sizeof(Next)); }};void Insert(node root){ node p = r...原创 2018-07-15 10:31:44 · 172 阅读 · 0 评论 -
二维树状数组模板(单点更新,区间求和)
const int MAXN = 1050;int N;int tree[MAXN][MAXN];int lowbit(int x){ return x&(-x);}void Add(int x,int y,int val){ for (int i=x ; i<=N ; i+=lowbit(i)) ...原创 2018-07-29 11:39:43 · 328 阅读 · 0 评论 -
主席树求区间第K小(大)数模板
#include <cstdio>#include <algorithm>using namespace std;const int MAXN = 1e5+10;struct T{ int L,R;//分别指向左右子树 int sum;//该节点所管辖区间范围内数的个数 T(){ sum = 0; }}Tree[MAXN*20];//尽量开大点...原创 2018-07-20 19:04:27 · 466 阅读 · 0 评论 -
01字典树模板
typedef struct Node* node;struct Node{ int val; int num; node Next[2]; Node() { val = num = 0; memset(Next,NULL,sizeof(Next)); }};void Insert(node root,int x,int flag)//flag的正负对应了加入和删除...原创 2018-07-15 15:26:11 · 178 阅读 · 0 评论 -
无向图求欧拉路径,回路 模板(Hierholzer 算法)
定义:欧拉回路:每条边恰好只走一次,并能回到出发点的路径欧拉路径:经过每一条边一次,但是不要求回到起始点欧拉回路存在性的判定:无向图每个顶点的度数都是偶数,则存在欧拉回路。有向图每个节顶点的入度都等于出度,则存在欧拉回路。欧拉路径存在性的判定:有向图 : 图连通,当且仅当该图所有顶点数的度数为0,或者一个顶点的度数为1,另一个顶点的度数为-1,其他顶点的度数为0。...原创 2018-07-29 18:43:56 · 5689 阅读 · 0 评论 -
Aho-Corasick automaton 模板
typedef struct Node* node;const int MAXNs = ;//模式串最大長度 const int MAXNS = ;//文章(待匹配串)最大長度 struct Node{ node next[26]; node fail;//失配指针 int sum; Node(){ sum = 0; fail = N...原创 2018-08-06 11:00:41 · 463 阅读 · 0 评论 -
ASCII码对照表
ASCII控制字符二进制 十进制 十六进制 缩写 可以显示的表示法 名称/意义 0000 0000 0 00 NUL ␀ 空字符(Null) 0000 0001 1 01 SOH ␁ 标题开始 0000 0010 2 02 STX ␂ 本文开始 0000 00...原创 2018-08-06 11:16:41 · 383 阅读 · 0 评论 -
OI超级加速挂
//--------------------------------------------------------------namespace fastIO { #define BUF_SIZE 100000 //fread -> read bool IOerror = 0; inline char nc() { static char buf[BUF_SIZE], *p...原创 2018-08-14 13:25:03 · 671 阅读 · 0 评论 -
经典三博弈基础情形模板(Nim,Wythoff Game,Bash Game)
Bash Game:只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个。最后取光者得胜。取胜的法则:如果n=(m+1)r+s,(r为任意自然数,s≤m),那么先取者要拿走s个物品,如果后取者拿走k(≤m)个,那么先取者再拿走m+1-k个,结果剩下(m+1)(r-1)个,以后保持这样的取法,那么先取者肯定获胜。Nim:有三堆各若干个物品,两个人轮流从某一堆...原创 2018-08-12 12:20:02 · 426 阅读 · 0 评论 -
蔡勒(Zeller)公式求星期几模板
用法:输入代表年月日的三个空格隔开的整数 ,输出该日期是星期几。如果日期不合法输出illegal。#include<iostream>using namespace std;bool m[] = {false,true,false,true,false,true,false,true,true,false,true,false,true};char b[7][10]=...原创 2018-08-12 13:21:58 · 595 阅读 · 0 评论 -
无向图找三元环模板
方法:暴力复杂度:O(msqrt(m))步骤:按点的度数分成两类,分别暴力①统计每个点的度数②入度<=sqrt(m)的分为第一类,入度>sqrt(m)的分为第二类③对于第一类,暴力每个点,然后暴力这个点的任意两条边,再判断这两条边的另一个端点是否连接因为m条边最多每条边遍历一次,然后暴力的点的入度<=sqrt(m),所以复杂度约为O(msqrt(m))④对于第二类,直接暴力任意三...原创 2018-07-14 20:48:06 · 627 阅读 · 0 评论 -
HDU - 2586 How far away ? (LCA求树上两点间距离模板题)
There are n houses in the village and some bidirectional roads connecting them. Every day peole always like to ask like this "How far is it if I want to go from house A to house B"? Usually it hard to...原创 2018-08-26 16:00:23 · 1274 阅读 · 0 评论 -
ST求区间最值模板
时间复杂度:预处理O(nlogn),查询O(1)。 const int MAXN = ;int board[MAXN];//存数据下标从1开始 int ma[MAXN][20],mi[MAXN][20];//区间最大值,区间最小值。 void ST_prework(int n){ for(int i=1 ; i<=n ; ++i)ma[i][0] = mi[i][0] = ...原创 2018-08-26 19:10:40 · 225 阅读 · 0 评论 -
POJ - 3368 Frequent values(线段树区间合并求区间内最长连续子串的长度模板题)
You are given a sequence of n integers a1 , a2 , ... , an in non-decreasing order. In addition to that, you are given several queries consisting of indices i and j (1 ≤ i ≤ j ≤ n). For each query, det...原创 2018-08-27 16:09:10 · 342 阅读 · 0 评论 -
二分模板大全
#include<iostream>#include<cstdio>using namespace std;const int MAXN = 100005;int mi[MAXN][50];//Çø¼ä×î´óÖµ£¬Çø¼ä×îСֵ¡£int lg[MAXN];int num[MAXN];//精确查找---用递归实现二分查找,精确查找目标元素的位...原创 2018-08-31 15:40:50 · 3110 阅读 · 0 评论 -
关于最大匹配,最小点覆盖,最少路径覆盖和最大独立集的总结
最小点覆盖:点覆盖的概念定义:对于图G=(V,E)中的一个点覆盖是一个集合S⊆V使得每一条边至少有一个端点在S中。最小点覆盖:就是点覆盖中点的个数最少的集合S。最小边覆盖:边覆盖的概念定义:边覆盖是图的一个边子集,使该图上每一节点都与这个边子集中的一条边关联,只有含孤立点的图没有边覆盖,边覆盖也称为边覆盖集,图G的最小边覆盖就是指边数最少的覆盖,图G的最小边覆盖的边数称为G的边...原创 2018-07-17 16:07:18 · 4001 阅读 · 0 评论 -
试除法质因数分解模板
#include <cstdio>using namespace std;void Split(int x){ for(int i=2 ; i*i<=x ; ++i){ if(x%i == 0){ printf("--%d\n",i);//输出质因数 while(x%i == 0)x /= i; } } if(x > 1)printf(...原创 2018-09-14 16:21:10 · 457 阅读 · 0 评论 -
Gym - 101775J Straight Master (差分)
A straight is a poker hand containing five cards of sequential rank, not necessarily to be the same suit. For example, a hand containing 7 club, 6 spade, 5 spade, 4 heart and 3 diamond forms a straigh...原创 2018-10-01 20:29:31 · 770 阅读 · 0 评论 -
矩阵行列式计算模板
long long a[205][205];long long solved(long long N,long long MOD){ int sign = 0; long long ans=1; for(int i=0;i<N;i++)//当前行 { for(int j=i+1;j<N;j++)//当前之后的每一行,因为每一行的当...原创 2018-09-20 17:42:44 · 2694 阅读 · 0 评论 -
SPOJ - LCS2 Longest Common Substring II (求若干个串的最长公共子串模板题)
A string is finite sequence of characters over a non-empty finite set Σ.In this problem, Σ is the set of lowercase letters.Substring, also called factor, is a consecutive sequence of characters oc...原创 2018-10-13 17:23:56 · 308 阅读 · 0 评论 -
关于模拟题的一些弱鸡总结
首先要感谢某位不知名大佬(当时没关注博客事后找不到了。。。)给了我很大的启发,然后本弱鸡在此写一下关于模拟题的一些个人见解(大佬求轻踩_(:з」∠)_)。众所周知,模拟题在ACM比赛中主要属于签到或铜牌层次的题,银牌模拟题并不多见。模拟题考点主要在思路,代码能力以及细节应对能力,而这几项在银牌题中大多由构造题来考查。构造题就是另一种东西了,构造题比模拟题费脑子多了我这个弱鸡就不掺和了。...原创 2018-11-05 19:02:35 · 306 阅读 · 0 评论 -
hdu1828 Picture(线段树+离散化+扫描线+基础周长并模板)两种方法
A number of rectangular posters, photographs and other pictures of the same shape are pasted on a wall. Their sides are all vertical or horizontal. Each rectangle can be partially or totally covered b...原创 2018-06-05 18:55:42 · 389 阅读 · 0 评论 -
邻接表基础常用模板
#define MAX_VEX 10//最大顶点数typedef int InfoType;typedef char VexType;//顶点的类型typedef int WeightType;//权值的类型 图的种类(有向图、无向图、加权有向图、加权无向图),采用枚举法(这一段可以选择性不写) typedef enum{ DG = 1, AG, WDG, WA...原创 2018-05-18 19:16:45 · 363 阅读 · 0 评论 -
数位DP模板
typedef long long ll; int a[20]; ll dp[20][state];//不同题目状态不同 ll dfs(int pos,/*state变量*/,bool lead/*前导零*/,bool limit/*数位上界变量*/)//不是每个题都要判断前导零 { //递归边界,既然是按位枚举,最低位是...原创 2018-05-17 11:12:44 · 164 阅读 · 0 评论 -
线段树模板
首先是建树:const int MAXN = 1005;//定义 MAXM 为线段最大长度int Tree[4*MAXN];// Data数组为 main 函数中读入的内容,Tree数组为需要查询的数的信息(如和、最值等),树的空间大小为线段最大长度的四倍!四倍!四倍! int Data[MAXN];void Build(int temp,int left,int right){//传入...原创 2018-05-14 19:33:04 · 375 阅读 · 0 评论 -
Manacher模板
#define MAXN 1000005char s[MAXN];//原字符串char New[2*MAXN];//处理过后得到的新字符串int p[2*MAXN];//记录以每个字符为中心的最长回文长度+1,注意是+1后的结果//这里为什么多出1一定要想明白,很重要。int Manacher(int len){ int id = 0; int mx = 0; ...原创 2018-02-01 13:41:26 · 178 阅读 · 0 评论 -
树状数组模板
#include &amp;amp;amp;amp;amp;lt;iostream&amp;amp;amp;amp;amp;gt;#include &amp;amp;amp;amp;amp;lt;cstdio&amp;amp;amp;amp;amp;gt;#include &amp;amp;amp;amp;amp;lt;cstring&amp;amp;amp;amp;amp;gt;#include &原创 2018-01-20 17:15:56 · 209 阅读 · 0 评论 -
求有向图的强连通分量 Tarjan算法学习笔记
网上翻了很多篇博客都比较难懂,最后终于找到一篇好理解的 推荐给大家http://blog.csdn.net/acmmmm/article/details/16361033 认真看肯定能懂,我当时是只用了十分钟就看明白了,写的真的很易懂。 不过他的代码我是没看懂,这里给一份我自己写的代码。#include &amp;amp;amp;amp;amp;amp;lt;iostream&amp;amp;amp;amp;amp;amp;gt;#include &a原创 2017-12-04 16:27:47 · 415 阅读 · 0 评论 -
Dijkstra 模板
#include &amp;lt;iostream&amp;gt;#include &amp;lt;cstdio&amp;gt;#include &amp;lt;cstring&amp;gt;#include &amp;lt;queue&amp;gt;#include &amp;lt;cstdlib&amp;gt;using namespac原创 2017-11-14 17:55:50 · 388 阅读 · 0 评论 -
JAVA 大数在acm中的应用
转载自:海克斯科技门1.首先,需要的头文件:import java.math.*; // 包含大数类的包 import java.util.*; // 包含输入头的包2.然后一个java程序的主体应该是这样:public class Main{ public static void main(String args[]){ ...转载 2018-05-18 21:23:35 · 410 阅读 · 0 评论 -
HDU1711 ——Number Sequence(KMP模板题)
Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 &lt;= M &lt;= 10000, 1 &lt;= N &lt;= 1000000). Your task is to find a number K which make a[K] = b[1], a[K + 1] = b[2],原创 2017-12-04 19:32:02 · 280 阅读 · 0 评论 -
HDU 1542 Atlantis(线段树——扫描线 :基础面积并模板,离散x坐标,从下向上扫描 )
There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. Some of these texts even include maps of parts of the island. But unfortunately, these maps describe diff...原创 2018-06-01 21:44:19 · 281 阅读 · 0 评论 -
树分治之点分治模板总结
点分治的时间复杂度为O(nlogn)。由于每次都是找重心,所以处理完一个大小为N的树后,每个子树的大小最大都为N/2,所以最多分治NlogN层,每层都是N所以是O(NlogN)。【具体流程】1,选取一个点,将无根树变成有根树 为了使每次的处理最优,我们通常要选取树的重心。 何为“重心”,就是要保证与此点连接的子树的节点数最大值最小,可以防止被卡。 重心求法: 1。dfs一次,算出以每个点...原创 2018-05-22 19:09:14 · 418 阅读 · 0 评论 -
Prim and Kruskal算法使用模板
Prim 邻接矩阵版:#define INF 0x3f3f3f3fconst int MAXN = 105;int N;int map[MAXN][MAXN];bool book[MAXN];//true为已经加入树的,false则相反 int lenth[MAXN];//注意有的博客这里解释为根到各个点的距离,其实应该是“树”到各个点的距离 int Prime(){...原创 2018-06-06 19:54:52 · 388 阅读 · 0 评论 -
二分查找模板
/*二分查找,找到该值在数组中的下标,否则为-1*/int binarySerach(int array[] , int length , int key) { int left = 1; int right = length; // 这里必须是 <= while (left <= right) { int mid = (left ...原创 2018-06-01 20:50:24 · 217 阅读 · 0 评论 -
最小费用最大流模板
const int INF = 0x3f3f3f3f;const int MAXN = ; struct Edge{ int value,flow,to,rev; Edge(){} Edge(int a,int b,int c,int d):to(a),value(b),flow(c),rev(d){}}; vector<Edge> E[MAXN]; inli...原创 2018-07-17 16:21:16 · 218 阅读 · 0 评论 -
最大流模板
const int MAXN = ;const int INF = 0x3f3f3f3f; struct Edge{ int flow,to,rev; Edge(){} Edge(int a,int b,int c):to(a),flow(b),rev(c){}}; vector<Edge> E[MAXN]; inline void Add(int from,i...原创 2018-07-17 16:24:28 · 222 阅读 · 0 评论 -
康托展开and逆展开c++实现
康托展开:#include <iostream>using namespace std;int board[10]{1,1,2,6,24,120,720,5040,40320,362880};//0-9的阶乘 bool book[10]; //标记数是否已经出现过 int main(){ string s; cin>>s; int sum = ...原创 2018-04-20 17:05:44 · 1206 阅读 · 0 评论 -
匈牙利算法模板
const int MAXN = 205;bool board[MAXN][MAXN];//存边 int color[MAXN];//用于染色法判断是否是二分图 int N,M;//N个点M条边 bool Judge(int x){ for(int i=1 ; i<=N ; ++i){ if(board[x][i] == 0)continue; if(color[x]...原创 2018-07-17 17:26:50 · 246 阅读 · 0 评论
分享