- 博客(175)
- 收藏
- 关注

原创 Python 程序设计快速入门简易教程
Python 程序设计快速入门简易教程Python语言快速检索一些需要知道的事一个简单的Python程序Python的基本数据类型Python的基本运算符Python的常用函数// import 库的用法分支语句循环结构字符串列表的使用元组自定义函数使用库编程Thanks for reading...Python语言快速检索Python的语法简洁,实用,假设你已有C++程序设计基础,接下来跟着我走,瞬间学会Python语言,对于信息学竞赛的学生可以用Python出随机数据是非常方便的,如果感兴趣,还可以
2020-06-03 17:20:56
1302

原创 Linux compare shell
for i in $(seq 1 100000);do ./gen ./sol ./bf if diff tmp.out tmpb.out ;then echo $i "AC ~ HAHAHA ~" else echo $i "WA ~ WA ~" exit 0 fidone
2016-11-17 22:00:08
1821
1

原创 Ubuntu里VIM的基本配置运行
sudo gedit /etc/vim/vimrc 打开配置文件,在最后面输入如下文字,保存:set nu //显示行号set tabstop=4 //设置TAB为4格set autoindent //设置自动缩进set cursorline //凸出显示该行set cursorcolumn //凸出显示该列color blue
2016-11-10 15:59:28
3591
原创 中国剩余定理(CRT)
人自出生起就有体力,情感和智力三个生理周期,分别为23,28和33天。一个周期内有一天为峰值,在这一天,人在对应的方面(体力,情感或智力)表现最好。现在给出三个日期,分别对应于体力,情感,智力出现峰值的日期。然后再给出一个起始日期,要求从这一天开始,算出最少再过多少天后三个峰值同时出现。分析:这个题由于数据范围小,那么直接可以通过枚举在这个数的最小公倍数范围内的所有数,找到最小的正整数解,然后后面的所有解都可以通过这个得到。的互素,那么如果不互素呢,怎么求解同余方程组?下的解是唯一的,解为。
2025-05-12 17:11:50
674
3
原创 长链剖分介绍
/ 邻接表存树// dep[u]:u的深度,len[u]:u所在长链长度// fa[u]:父节点,hson[u]:长儿子int top[N];// top[u]:u所在长链的链顶// 第一次DFS:计算深度、长儿子、链长len[u] = 1;dfs1(v, u);// 更新长儿子(选择深度最大的子树)// 第二次DFS:确定链顶// 长儿子继承链顶dfs2(v, v);// 其他儿子新建链// 根据题目确定根节点return 0;
2025-03-05 16:18:18
150
原创 状态压缩DP (最短Hamilton路径)
最短Hamilton路径。Hamilton路径的定义是从 0 到。不重不漏地经过每个点恰好一次。标号,求起点 0 到终点。个点的带权无向图。
2025-02-27 14:00:36
892
原创 线段树动态开点
也就是说,其实我们不需要一上来就把所有的节点全部建立起来,只需要在用到一个节点的时候再建立一个节点就可以了。对于线段树这种暴力结构,其空间效率是比较底下的 O(4∗n)。因此,我们想到一个方法来优化——动态开点。###洛谷线段树1示例代码。
2024-07-05 23:35:40
577
原创 HDU1285拓扑排序模板题
#include<bits/stdc++.h>using namespace std;const int maxn=510;int rd[maxn],ans[maxn];vector<int> a[maxn];priority_queue<int ,vector<int>,greater<int> > q;int main(){ int n,m; while(cin>>n>>m){ for(int i=1
2022-05-02 16:27:29
479
原创 POJ2418字典树
#include<iostream>#include<cstdio>#include<cstring>using namespace std;const int maxn=1000010;struct node{int p,ch[130];}a[maxn];int cnt=1,sum=0;char t[35];void out(int rt,int L){ for(int i=0;i<=129;i++){ int u=a[rt].ch[i];
2022-04-12 21:14:47
493
原创 字典树POJ2001
#include<iostream>#include<cstdio>#include<cstring>using namespace std;const int maxn=100010;struct node{ int p,ch[30],count; }a[maxn];int cnt,n;char tmp[maxn][30];int main(){ cnt=1; n=0; while(gets(tmp[++n])){ if(!tmp[n][0]
2022-04-10 21:39:08
450
原创 字典树poj2503
#include<iostream>#include<cstdio>#include<cstring>using namespace std;const int maxn=1000010;struct node{ int p,ch[30]; char t[15];}a[maxn];int cnt,n,T;char s1[15],s2[15],tmp[30];int main(){ cnt=1; while(gets(tmp)){ if(!t
2022-04-10 19:55:29
659
原创 POJ3630 字典树
#include<iostream>#include<cstdio>#include<cstring>using namespace std;const int maxn=100010;struct node{int p,ch[30];}a[maxn];int cnt,n,T;int main(){ char x[25]; cin>>T; while(T--){ cnt=0; memset(a,0,sizeof(a)); int f
2022-04-10 16:02:38
427
原创 SPLAY的各种操作
#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;const int maxn=100010;struct node{ int v,s,fz,f,ch[2]; //ch[0]:left;ch[1]:right;}a[maxn];int root=1,t[maxn];void push_up(int rt){ int
2022-04-05 21:52:52
537
原创 splay poj1442
#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;const int maxn=100010;struct node{ int v,s,f,ch[2]; //ch[0]:left;ch[1]:right;}a[maxn];int root=1,t[maxn];void push_up(int rt){ int l=
2022-04-05 19:55:59
133
原创 SPLAY 排序模板
#include<bits/stdc++.h>using namespace std;const int maxn=100010;struct node{ int v,s,f,ch[2]; //ch[0]:left;ch[1]:right;}a[maxn];int root=1;void out(int rt){ if(rt){out(a[rt].ch[0]); printf("%d ",a[rt].v); out(a[rt].ch[1]);}}void rotate(i
2022-04-03 20:50:16
431
原创 POJ1442 TREAP名次树
#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;const int maxn=30010;struct node{ int v,w,s; node *fa,*l,*r; node(){s=1;w=rand();fa=l=r=NULL;}};node *root;int a[maxn];int js(node
2022-03-29 19:58:42
368
原创 TREAP 参考程序
//动态#include<bits/stdc++.h>using namespace std;struct node{ int v,w; node *fa,*l,*r; node(){w=rand();fa=l=r=NULL;}};node *root;void yx(node *B,node *A){ node *f=A->fa,*y=B->r; B->r=A; A->fa=B; A->l=y; if(y!=NULL)y->fa=
2022-03-27 20:01:29
477
原创 ural 1553 树剖+线段树
#include<bits/stdc++.h>using namespace std;#define Mid ((l+r)>>1) #define lson rt<<1,l,Mid #define rson rt<<1|1,Mid+1,r const int maxn=100000+10;int to[maxn*2],nex[maxn*2],beg[maxn];int fa[maxn],dis[maxn],siz[maxn],son[ma
2022-03-22 19:35:05
471
1
转载 树上差分(LUOGU3128)
#include<bits/stdc++.h>using namespace std;typedef long long ll;const int inf = 0x3f3f3f3f;const int mod = 1e8;const int Max = 5e4 + 10;const int Max2 = 5e3 + 10;struct Edge{ int to, next;}edge[Max<<1]; int n, k;int head[Max], tot;
2021-05-25 19:46:59
200
原创 旋转卡壳,最远的距离
#include <cmath> #include <algorithm> #include <iostream> using namespace std; #define MAXN 50005 struct Point{ int x, y; bool operator < (const Point& _P) const{ return y<_P.y||(y==_P.y&&x<_P.
2021-03-09 21:19:05
229
原创 二维凸包 模板代码
#include<iostream>#include<cstdio>#include<cmath>#include<algorithm>const int maxn=10000+10;using namespace std;struct node{double x,y;};node p[maxn],z[maxn];bool cmp(node u,node v){return u.x<v.x;}bool cmpxl(node a,node
2021-03-02 20:35:22
222
原创 最小费用最大流模板
#define REP(i, s, e) for(register int i = s; i <= e ;i++)#include<bits/stdc++.h>using namespace std;const int maxn = 5000 + 5, maxm = 50000 + 5, inf((((1 << 30) - 1) << 1) + 1);int bg[maxn], ne[maxm << 1], to[maxm << 1]
2021-02-25 21:09:23
207
原创 网络流模板程序
网络流模板程序EK#include<bits/stdc++.h>using namespace std;const int maxn = 210;const long long INF =1152921504606846976;long long cap[maxn][maxn], flow[maxn][maxn];long long n,m,p[maxn];long long a[maxn];;int main(){ int s,t; cin>>n>>
2021-02-21 20:44:47
189
转载 求树的直径
树的直径,即树上的最长路径,显然,树的直径可以有很多条(考虑一棵菊花)。接下来我们考虑如何求出一棵树的直径。有很多种O(n)的算法。算法1:我们任取树中的一个节点x,找出距离它最远的点y,那么点y就是这棵树中一条直径的一个端点。我们再从y出发,找出距离y最远的点就找到了一条直径。这个算法依赖于一个性质:对于树中的任一个点,距离它最远的点一定是树上一条直径的一个端点。下面给出证明。考虑这样...
2018-12-29 14:49:22
1309
原创 POJ1655 树的重心
#include&amp;lt;iostream&amp;gt;#include&amp;lt;cstdio&amp;gt;#include&amp;lt;vector&amp;gt;using namespace std;const int maxn=50000+5,inf=100000000;int sum[maxn];vector &amp;lt;int&am
2018-12-29 14:31:11
310
原创 数据结构之栈的使用
数据结构之栈的使用数制转换括号匹配检验后缀表达式表达式求值 &amp; 中缀表达式转后缀表达式递归 &amp; 深度优先搜索由于栈结构具有后进先出的固有特性,致使栈称为程序设计中的有用工具。数制转换括号匹配检验后缀表达式表达式求值 &amp; 中缀表达式转后缀表达式递归 &amp; 深度优先搜索...
2018-12-16 18:32:34
393
原创 C++STL系列 队列的使用
/*queue的成员函数 empty 测试容器是否为空,为空时返回true size 返回容器的大小 front 返回队列的第一个元素,即最早被压进队列的元素//队首 back 返回队列的最后一个元素,即最晚被压进队列的元素//队尾 push 把元素添加至队列尾 pop 弹出队列首元素*/#includeusing namespace std
2017-09-26 09:30:44
3129
原创 C++STL系列 结构体运算符重载及优先队列的使用
#includeusing namespace std;struct node{ int x,y; bool operator <(const node b)const{ return this->x>b.x; }};priority_queue q;int main(){ int i,j,k,m,n; cin>>n; for(i=1;i<=n;i++){ node
2017-09-26 09:03:06
1330
原创 POJ 1463 TREE DP
#include#include#includeconst int maxn=6000+10;using namespace std;int to[maxn],beg[maxn],nex[maxn],e;int fa[maxn],f[maxn][2],p[maxn];void dfs(int x){ p[x]=1; for(int i=beg[x];i;i=nex[i]){
2017-09-03 21:47:19
502
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人