
---------模板---------
Lazer2001
天涯何处无芳草
只是白兔寻不到
展开
-
黑科技 rand()
大家都很强, 可与之共勉。然而并不知道怎么证明。。。#include <cstdio>inline int rand ( ) { static int seed = 233; return seed = ( int ) seed * 48271LL % 2147483647; }int main () { while ( 1 ) printf ( "%原创 2017-05-26 08:49:44 · 2669 阅读 · 0 评论 -
网络流Dinic模板
之前的被卡常数了……class Network {private : struct edge { int to, w, nxt ; edge ( ) { } edge ( int to, int w, int nxt ) : to ( to ), w ( w ), nxt ( nxt ) { } }原创 2017-12-18 09:19:15 · 416 阅读 · 0 评论 -
我的雷打不动的代码风格
大家都很强, 可与之共勉 。头文件#左边有一个空格,include右边会有一个空格。除了<bits/stdc++.h>之外都用以c为前缀的头文件而不是.h为后缀。不会using namespace std ;一般习惯:花括号不换行,而且左花括号{左边一定会有两个空格。 main函数的返回值是int,且位于整个函数的末尾。(``)的左右两边都必须有空格。[的左边有空格。缩进:缩进一原创 2017-12-05 10:43:49 · 554 阅读 · 1 评论 -
手写堆heap(STL的heap算法)
大家都很强, 可与之共勉 。发现自己一千多行的模板有问题23333template < class T >class Heap { private : T h [N] ; int len ; public : Heap ( ) { len = 0 ; } inline void push ( const T&原创 2017-11-03 21:11:43 · 485 阅读 · 1 评论 -
读入优化? fread ??? NAIVE !!! streambuf -- sgetn
大家都很强, 可与之共勉 。比fread快的读入优化 使用底层的streambuf, 用rdbuf ( )获取。# include <cctype># include <cstdio># include <iostream>inline int read ( ) {# define SIZE 1000005 static std :: streambuf *fb ( std ::原创 2017-11-03 16:25:07 · 891 阅读 · 0 评论 -
LIS nlogn 模板
大家都很强,可与之共勉。inline int Lis ( int* s, int n ) { if ( n == 0 ) return 0 ; int len ( 1 ) ; src [1] = s [1] ; for ( int i = 2 ; i <= n ; ++ i ) { src [( s [i] > src [len] ) ? (原创 2017-10-23 17:12:47 · 324 阅读 · 0 评论 -
计数器
大家都很强, 可与之共勉。点这里。欢迎大家来这里开车!#include <cstdio>int cnt;int main () { printf ( "Page view = %d\n", ++cnt ); puts ( "Thank You!" ); return 0;}原创 2017-05-29 21:51:47 · 6938 阅读 · 1 评论 -
可撤销并查集模板(按秩合并)
大家都很强, 可与之共勉 。用按秩合并实现,不能路径压缩。class UFS {private : int *fa, *rank ; std :: stack < std :: pair < int*, int > > stk ; public : UFS ( ) { } UFS ( int n ) { fa = new int [原创 2017-09-22 11:51:29 · 3814 阅读 · 0 评论 -
CF被裱了之后很不开心,明明都是我手打的......
根据我专业的分许,是没有一个很有写的模板。于是,做了一下午…# include <map># include <set># include <cmath># include <ctime># include <queue># include <stack># include <bitset># include <cctype># include <cstdio># include原创 2017-10-17 16:52:01 · 326 阅读 · 0 评论 -
各类杂项 [各种模板]
大家都很强, 可与之共勉。所有using namespace std;的都是纸老虎。#include "cstdio"#include "cctype"#include "cstdlib"#include "cstring"typedef long long LL;const double eps = 1e-9;const int MOD = 1000000007, MAXN = (int)原创 2017-03-22 13:28:05 · 393 阅读 · 0 评论 -
Win下对拍模板 ( bat )
大家都很强,可与之共勉。@echo offfor /l %%i in (1,1,100000000000000000) do ( make.exe a.exe b.exe fc /a /n out1.txt out2.txt if errorlevel 1 ( echo WAAAAAAA pause ) ech原创 2017-09-14 16:41:55 · 379 阅读 · 0 评论 -
数论 高斯消元模板
大家都很强,可预与之共勉。高斯消元法可以用于解决n元一次方程组的方法。就是消元然后回代求解。# include <cstdio># include <algorithm>inline double fabs ( double a ) { return a > 0 ? a : -a ;}const int N = 105 ;const double eps = 1e-8 ;double原创 2017-08-19 08:20:01 · 338 阅读 · 0 评论 -
网络流Dinic模板 QQQ
class Network {private : struct edge { int to, w, nxt ; edge ( ) { } edge ( int to, int w, int nxt ) : to ( to ), w ( w ), nxt ( nxt ) { } } g [N << 1] ;原创 2017-07-11 08:31:59 · 341 阅读 · 0 评论 -
史上最强图解Treap总结, 不是浅谈!
大家都很强, 可与之共勉。Treap = Tree + Heap. 树堆,在数据结构中也称Treap,是指有一个随机附加域满足堆的性质的二叉搜索树,其结构相当于以随机数据插入的二叉搜索树。其基本操作的期望时间复杂度为O(logn)。相对于其他的平衡二叉搜索树,Treap的特点是实现简单,且能基本实现随机平衡的结构。Treap 维护堆的性质的方法只用到了左旋和右旋, 编程复杂度比Splay小一点,原创 2017-06-01 16:59:10 · 15040 阅读 · 3 评论 -
读入输出优化 黑科技 快过fread&&fwite
大家都很强, 可与之共勉 。可能还是比不上mmap 但是使用了iostream底层的streambuf,效果极快。namespace In {# define In_Len 2000000 static std :: streambuf *fb ( std :: cin.rdbuf ( ) ) ; static char buf [In_Len], *ss ( 0...原创 2017-11-06 15:05:04 · 1596 阅读 · 1 评论