摘要: ```cpp // 初始化n个元素 void init(int n) { for(int i=0;i 阅读全文
posted @ 2019-07-16 13:41 prestige 阅读(257) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include using namespace std; const int N=25; int a[N],len; long long l,r,dp[N][N]; long long dfs(int pos,int st,long lo 阅读全文
posted @ 2019-07-16 13:40 prestige 阅读(121) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include include include include using namespace std; const int M=200005; int Cnt,n,m,l,r,k,q,ans,sum[M 1; build 阅读全文
posted @ 2019-07-16 13:39 prestige 阅读(198) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include include include include using namespace std; const int N=105; int n,m,x,y,MAP[N][N],indegree[N]; void t 阅读全文
posted @ 2019-07-16 13:38 prestige 阅读(63) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include include using namespace std; define ll long long const int Maxn=100001; int n,m,r,p,a[Maxn],x,y,now[Max 阅读全文
posted @ 2019-07-16 13:36 prestige 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2019-07-16 13:35 prestige 阅读(124) 评论(0) 推荐(0) 编辑
摘要: ```cpp long long read(){ long long X=0,W=1; char ch=0; while(ch'9'){ if(ch=='-'){ W=-1; } ch=getchar(); } while(ch>='0'&&ch9){ out(X/10)... 阅读全文
posted @ 2019-07-16 13:34 prestige 阅读(112) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include include include include using namespace std; const int N=200005; int n,m,s,tot,Next[N],head[N],to[N]; b 阅读全文
posted @ 2019-07-16 13:33 prestige 阅读(218) 评论(0) 推荐(0) 编辑
摘要: ```cpp #include #include #include #include using namespace std; const int N=20005; int tot,n,ans; char s[55]; struct Node{ int pos,val; }trie[N][30]; void insert(char *s,int rt){ int Max=0,x; fo... 阅读全文
posted @ 2019-07-16 13:32 prestige 阅读(114) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include define Maxn 1000500 const double Pi=acos( 1); using namespace std; int n,m,r[Maxn 1] 1)|((i&1)?n 1:0); fft(b,1); fft(c,1);//DFT 阅读全文
posted @ 2019-07-16 13:32 prestige 阅读(1201) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include define MAXN 100010 define inf 0x3f3f3f3f using namespace std; struct node{ int l,r;//区间[l,r] int add;// 阅读全文
posted @ 2019-07-16 13:31 prestige 阅读(118) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include define Maxn 5000 define Pi 3.1415926535898 using namespace std; int n,m; struct complex {complex (double xx=0,double yy=0){x=xx 阅读全文
posted @ 2019-07-16 13:31 prestige 阅读(486) 评论(0) 推荐(0) 编辑
摘要: ```cpp long long pow_mod(long long a,long long b,long long r){ long long ans=1,buff=a; while(b){ if(b&1) ans=(ans buff)%r; buff=(buff buff)%r; b =1; } 阅读全文
posted @ 2019-07-16 13:30 prestige 阅读(104) 评论(0) 推荐(0) 编辑
摘要: ```cpp #include #include #include using namespace std; const int power = 1; //每次运算的位数为10的power次方,在这里定义为了方便程序实现 const int base = 10; //10的power次方。 //要压位的时候,只需改power 和 base即可,如压... 阅读全文
posted @ 2019-07-16 13:30 prestige 阅读(371) 评论(0) 推荐(0) 编辑
摘要: ```cpp memset(isprime,1,sizeof(isprime)); isprime[1]=false; for(int i=2;i 阅读全文
posted @ 2019-07-16 13:29 prestige 阅读(396) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include include include include using namespace std; const int N=10005,M=500005,INF=2147483647; int n,m,s,Cnt,d 阅读全文
posted @ 2019-07-16 13:23 prestige 阅读(104) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include include using namespace std; using namespace std; const int N=500005; int cnt,fa[N],ans[N],head[N],rhea 阅读全文
posted @ 2019-07-16 13:16 prestige 阅读(78) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include using namespace std; const int maxN=300; const int maxM=maxN maxN 4; const int inf=2147483647; class Ed 阅读全文
posted @ 2019-07-16 13:15 prestige 阅读(469) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include include include using namespace std; const int N=205; bool gra[N][N],state[N]; int result[N],ans,n,m,s, 阅读全文
posted @ 2019-07-16 13:14 prestige 阅读(77) 评论(0) 推荐(0) 编辑
摘要: ```cpp #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,m,n) for(i=m;i::iterator it=s.begin();i... 阅读全文
posted @ 2019-07-16 13:14 prestige 阅读(77) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include include include include include include include include include using namespace std; bool vis[200001];i 阅读全文
posted @ 2019-07-16 13:13 prestige 阅读(163) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include include include include include include include include include using namespace std; const int maxN=100 阅读全文
posted @ 2019-07-16 13:12 prestige 阅读(99) 评论(0) 推荐(0) 编辑
摘要: ```cpp //kosaraju #include #include #include #include #include #include #include using namespace std; const int N=10005; int n,m,cnt,head[N],rhead[N],t,rt,q[N],top,ans,rcnt,Cnt[N],sum[N],number; bool ... 阅读全文
posted @ 2019-07-16 13:11 prestige 阅读(134) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include include include using namespace std; const int N=50005; int n,m,head[N],dfs[N],stack[N],low[N],cnt,t,to 阅读全文
posted @ 2019-07-16 13:10 prestige 阅读(98) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include include include using namespace std; const int N=10005; int n,m,cnt,rcnt,head[N],rhead[N],t,rt,ans; boo 阅读全文
posted @ 2019-07-16 13:09 prestige 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 树状数组求逆序对 cpp include include include include include include include using namespace std; const long long N=1000005; long long t,n,aa[N],c[N],i,ans; s 阅读全文
posted @ 2019-07-16 13:08 prestige 阅读(130) 评论(0) 推荐(1) 编辑
摘要: ```cpp 这是一本教你怎样在比赛中骗分的书。 新 版 骗 分 导 论 THE NEW GUIDE OF CHEATING IN INFORMATICS OLYMPIAD 蒟 蒻 的 宝 书 目录 第1章 绪论 第2章 从无解出发 2.1 无解情况 2.2 样例——白送的分数 第3章 “艰苦朴素永不忘” 3.1 模拟 3.2 万能钥匙——DFS 第4章 骗分的关键——猜想 ... 阅读全文
posted @ 2019-07-16 13:07 prestige 阅读(1056) 评论(0) 推荐(2) 编辑
摘要: ```cpp 归并(Merge)排序法是将两个(或两个以上)有序表合并成一个新的有序表,即把待排序序列分为若干个子序列,每个子序列是有序的。然后再把有序子序列合并为整体有序序列。 目 录 1归并排序 2归并操作 3算法描述 4比较 5用途 5.1 排序 5.2 求逆序对数 6示例代码 6.1 归并排 阅读全文
posted @ 2019-07-16 13:05 prestige 阅读(209) 评论(0) 推荐(0) 编辑
摘要: ```cpp 一、定义 图的割点 一个无向连接图中,如果删除某个顶点后,图不再连同(即任意两点之间不能互相到达) ,称这样的顶点为割点 或:某个点是割点当且仅当删除该点和与该点相关联的边后图变得不连通。 图的割边/桥: 一个无向连通图中,如果删除某条边后,图不再连通,这条边就为割边。 或:某条边是割边当且仅当删除该边后图变的不连通。 二. 求割点,桥 使用dfs(深搜)来求割点和桥。先... 阅读全文
posted @ 2019-07-16 13:02 prestige 阅读(312) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2019-07-16 13:00 prestige 阅读(85) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include include include using namespace std; const int N=1000005; int t,cnt,head[N],son[N],dfn[N],low[N],n,ans, 阅读全文
posted @ 2019-07-16 12:48 prestige 阅读(102) 评论(0) 推荐(0) 编辑
摘要: ```cpp #include #include #include #include const int N=10005; using namespace std; vectorG[N]; int n,m,low[N],dfn[N]; int father[N]; int tim; void Tarjan(int i,int Father){ father[i]=Father; d... 阅读全文
posted @ 2019-07-16 12:48 prestige 阅读(88) 评论(0) 推荐(0) 编辑
摘要: ```cpp 【题目描述】: 停电,漆黑的夜晚。 ACM + +是一家电力公司。该公司拥有数个发电厂,每一个供应一个小面积,这些发电厂给这个公司带来了很多的麻烦,在某些地区没有足够的电力,而在其他地区却有大量的盈余。 ACM ++因此决定将一些发电厂连接成一个网络。当然第一阶段,没有必要将所有的发电 阅读全文
posted @ 2019-07-16 12:47 prestige 阅读(128) 评论(0) 推荐(0) 编辑
摘要: ```cpp 【题目描述】: 蒟蒻刚刚学了点图论,现在他面对一张无向连通图,他想问你: 最少添加多少条边,使得任意两点之间有两条无公共边的路(可以有公共点)。 【输入描述】: 第一行n,m,n个点(编号1 n)m条边; 接下来m行,每行u,v; 表示u到v之间有一条无向边(可能重复描述一条边); 【 阅读全文
posted @ 2019-07-16 12:45 prestige 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 题面:https://www.luogu.org/problemnew/show/P2746 cpp 对于子任务A,求需要给多少个学校发软件,即为求有多少个入度为0的点 因为对于对于每个入度不为0的点一定可以从一个其他点走到。 对于子任务B,求入度为0的点个数与出度为0的点个数的最大值,需要添多少条 阅读全文
posted @ 2019-07-16 12:44 prestige 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 题面:https://www.luogu.org/problemnew/show/P2613 cpp 分析题目,发现c可以转化为a∗b^−1,即本题就是求b在mod p的意义下的逆元。特别的,当gcd(a,p)≠1,方程无解,因此a也无逆元。 Code: include include includ 阅读全文
posted @ 2019-07-16 12:43 prestige 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 题面:https://www.luogu.org/problemnew/show/P2261 cpp 首先,我们处理一下n =k的情况,因为这种情况很好处理: G(n,k)=k%1+k%2+......+k%n,那么,当n =k时,n =k的部分k%i就是k,然后就是n include includ 阅读全文
posted @ 2019-07-16 12:43 prestige 阅读(157) 评论(0) 推荐(0) 编辑
摘要: ```cpp include using namespace std; const int N = 100005; int ch[N][2], par[N], val[N], cnt[N], size[N], rev[N], root, ncnt; int n, m, x, y; bool chk( 阅读全文
posted @ 2019-07-16 12:41 prestige 阅读(147) 评论(0) 推荐(0) 编辑
摘要: ```cpp 【题目描述】: 每天,农夫约翰的N头奶牛总是按同一顺序排好队,有一天,约翰决定让一些牛玩一场飞盘游戏(Ultimate Frisbee),他决定在队列里选择一群位置连续的奶牛进行比赛,为了避免比赛结果过于悬殊,要求挑出的奶牛身高不要相差太大。 约翰准备了Q组奶牛选择,并告诉你所有奶牛的 阅读全文
posted @ 2019-07-16 12:38 prestige 阅读(110) 评论(0) 推荐(0) 编辑
摘要: ```cpp 题目描述 为了检测生产流水线上总共N件产品的质量,我们首先给每一件产品打一个分数A表示其品质,然后统计前M件产品中质量最差的产品的分值Q[m] = min{A1, A2, ... Am},以及第2至第M + 1件的Q[m + 1], Q[m + 2] ... 最后统计第N M + 1至 阅读全文
posted @ 2019-07-16 12:36 prestige 阅读(216) 评论(0) 推荐(0) 编辑