摘要: ```cpp Description 如题,已知一个数列(下标从1开始计数),你需要进行下面两种操作: 1.将某区间每一个数,加上x 2.获取某一个数的值 Input 第一行包含两个整数N、M,分别表示该数列数字的个数和操作的总个数。 第二行包含N个用空格分隔的整数,第i个数字表示数列第i项的初始值 阅读全文
posted @ 2019-07-16 23:39 prestige 阅读(84) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 如题,已知有N个元素组成的数列(下标从1开始计数),你需要进行下面两种操作: 1.将某一个数加上x 2.求出某区间每一个数的和 【输入描述】: 第一行包含两个整数N、M,分别表示该数列数字的个数和操作的总个数。 第二行包含N个用空格分隔的整数,其中第i个数字表示数列第i 阅读全文
posted @ 2019-07-16 22:57 prestige 阅读(133) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 因为某国被某红色政权残酷的高压暴力统治。美国派出将军uim,对该国进行战略性措施,以解救涂炭的生灵。 该国有n个城市,这些城市以铁路相连。任意两个城市都可以通过铁路直接或者间接到达。 uim发现有些铁路被毁坏之后,某两个城市无法互相通过铁路到达。这样的铁路就被称为key 阅读全文
posted @ 2019-07-16 16:01 prestige 阅读(111) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 在幻想乡,上白泽慧音是以知识渊博闻名的老师。春雪异变导致人间之里的很多道路都被大雪堵塞,使有的学生不能顺利地到达慧音所在的村庄。因此慧音决定换一个能够聚集最多人数的村庄作为新的教学地点。 人间之里由N个村庄(编号为1..N)和M条道路组成,道路分为两种一种为单向通行的, 阅读全文
posted @ 2019-07-16 16:00 prestige 阅读(168) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 有向图强连通分量:在有向图G中,如果两个顶点vi,vj间(vi vj)有一条从vi到vj的有向路径,同时还有一条从vj到vi的有向路径,则称两个顶点强连通(strongly connected)。如果有向图G的每两个顶点都强连通,称G是一个强连通图。有向图的极大强连通子 阅读全文
posted @ 2019-07-16 15:59 prestige 阅读(168) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P3627 cpp 本题可以将图中强连通分量缩点后再跑最长路即可。 Code: include include include define N 500005 using namespace std; struct e 阅读全文
posted @ 2019-07-16 15:59 prestige 阅读(106) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P1407 cpp 本题建图时: 夫妻之间:女孩指向男孩 情人之间:男孩指向女孩 然后Tarjan求强连通分量,对于一对夫妻,如果两人在同一个强连通分量里,那么这对婚姻就是不安全的,反之,则是安全的。 Code: in 阅读全文
posted @ 2019-07-16 15:58 prestige 阅读(136) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P2341 阅读全文
posted @ 2019-07-16 15:19 prestige 阅读(134) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P2863 cpp 本题直接用tarjan求出图中节点数大于一的强联通分量个数,然后输出即可。 Code: include include include include include include include 阅读全文
posted @ 2019-07-16 15:16 prestige 阅读(144) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P4391 cpp 本题中n next[n]即为字符串最小长度的循环节。 Code: include include include include include include using namespace st 阅读全文
posted @ 2019-07-16 15:11 prestige 阅读(183) 评论(0) 推荐(0)
摘要: 题面:http://poj.org/problem?id=1961 cpp 本题的重点在于如果一个串是周期串的话,那么每次错位的位置应该是一个循环节。所以当i next[i]=x i时,此时next[i]就是一个循环节。 Code: include include include include i 阅读全文
posted @ 2019-07-16 15:09 prestige 阅读(198) 评论(0) 推荐(0)
摘要: 题面:http://poj.org/problem?id=2406 cpp 本题中的可能的最短循环节即为KMP中的next[len 1],若len next[len 1]能被len整除,则有最短循环节,否则输出1。 Code: include include include using namesp 阅读全文
posted @ 2019-07-16 15:08 prestige 阅读(81) 评论(0) 推荐(0)
摘要: ```cpp int[] getNext(String ps){ next[0]= 1; int j=0; int k= 1; while(j 阅读全文
posted @ 2019-07-16 15:08 prestige 阅读(111) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P2024 阅读全文
posted @ 2019-07-16 15:07 prestige 阅读(135) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 幼儿园里有N个小朋友,1xhgww老师现在想要给这些小朋友们分配糖果,要求每个小朋友都要分到糖果。但是小朋友们也有嫉妒心,总是会提出些要求,比如小明不希望小红分到的糖果比他的多,于是在分配糖果的时候lkhgww需要满足小朋友们的K个要求。幼儿园的糖果总数是有限的,1xh 阅读全文
posted @ 2019-07-16 15:04 prestige 阅读(118) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P1892 cpp 本题可以把朋友并在一起,用一个数组记录敌人,然后把敌人的敌人和自己并在一起即可。 Code: include include include include include include incl 阅读全文
posted @ 2019-07-16 15:04 prestige 阅读(112) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P1955 cpp 本题可以把等于的并在一起,碰到不等于的就判断是否矛盾。由于数据比较大,注意要离散化。 Code: include include include include include include in 阅读全文
posted @ 2019-07-16 15:04 prestige 阅读(156) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 当排队等候喂食时,奶牛喜欢和它们的朋友靠近些。FJ 有N头奶牛,编号从1到N,沿一条直线站着等候喂食。奶牛排在队伍中的顺序和它们的编号是相同的。因为奶牛相当苗条,所以可能有两头或者更多奶牛站在同一位置上。如果我们想象奶牛是站在一条数轴上的话,允许有两头或更多奶牛拥有相同 阅读全文
posted @ 2019-07-16 15:03 prestige 阅读(158) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P3106 cpp 本题三次建图: 先将GPS1的图存入邻接表。跑一遍dijkstra 然后将GPS2的图再存入邻接表。再跑一遍dijkstra 最后将2次跑过的dijkstra,得到的最短路后所发出的警告数(分别不在 阅读全文
posted @ 2019-07-16 15:01 prestige 阅读(165) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P2966 cpp 本题直接枚举过路草地收费最大点,然后跑n遍dijkstra即可。 Code: include using namespace std; const int N=255; int n,m,q,p[N] 阅读全文
posted @ 2019-07-16 15:01 prestige 阅读(102) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 给定一张无向图,求图中一个至少包含 3个点的环,环上的节点不重复,并且环上的边的长度之和最小。该问题称为无向图的最小环问题。在本题中,你需要输出最小环的边权之和。若无解,输出 “No solution.”。图的节点数不超过 100。 【输入描述】: 第一行两个正整数 n 阅读全文
posted @ 2019-07-16 15:00 prestige 阅读(256) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: N只奶牛(编号为1…N)在进行一个特别的接力赛跑,这个比赛特别之处在于,若干只奶牛可以同时跑。 在t=0时刻,牛1开始沿着跑道跑,L_1秒后跑完一圈重新到达起点线。通常,牛i跑完一圈需要的时间为L_i秒。当牛1重新越过起点线的瞬间,它会通知另外M_1只奶牛立即起跑。通常 阅读全文
posted @ 2019-07-16 14:47 prestige 阅读(109) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 有N个股票经济人可以互相传递消息,他们之间存在一些单向的通信路径。现在有一个消息要由某个人开始传递给其他所有人,问应该由哪一个人来传递,才能在最短时间内让所有人都接收到消息。若不存在这样一个人,则输出disjoint。 【输入描述】: 第一行为n,代表总人数,当n=0时 阅读全文
posted @ 2019-07-16 14:45 prestige 阅读(121) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: N个虫洞,M条单向跃迁路径。从一个虫洞沿跃迁路径到另一个虫洞需要消耗一定量的燃料和1单位时间。虫洞有白洞和黑洞之分。设一条跃迁路径两端的虫洞质量差为delta。 1.从白洞跃迁到黑洞,消耗的燃料值减少delta,若该条路径消耗的燃料值变为负数的话,取为0。 2.从黑洞跃 阅读全文
posted @ 2019-07-16 14:44 prestige 阅读(352) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 平面上有n个点,每个点的坐标均在 10000~10000之间。其中的一些点之间有连线。若有连线,则表示可从一个点到达另一个点,即两点间有通路,通路的距离为两点间的直线距离。现在的任务是找出从一点到另一点之间的最短路径。 【输入描述】: 输入文件共n+m+3行,其中:第一 阅读全文
posted @ 2019-07-16 14:15 prestige 阅读(118) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的。 【输入描述】: 多组数据:每组数据描述如下: 输入n,m,点的编号是1~n,然后是m行,每行4个数 a,b,d,p,表示 阅读全文
posted @ 2019-07-16 14:11 prestige 阅读(105) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P3147 cpp 本题设f[i][j]表示左端点为j,能合并出i这个数字的右端点的位置 由于位置为j的数和位置为f[i 1][j]的数可以合成一个i 1 那么位置为f[i 1][j]的数和位置为f[i 1][f[i 阅读全文
posted @ 2019-07-16 14:05 prestige 阅读(119) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P3205 阅读全文
posted @ 2019-07-16 14:04 prestige 阅读(108) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P4170 cpp 本题设f[i][j]为将i~j染色所花的最小染色次数 那么当i==j时,f[i][j]=1 当i!=j&&s[i]==s[j]时,可以看做是在第一次涂时多涂一格 那么就有f[i][j]=min(f[ 阅读全文
posted @ 2019-07-16 14:03 prestige 阅读(129) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 我们给出了“正则括号”序列的归纳定义: 空序列是一个正则括号序列, 如果S是一个正则括号序列,则(s)和[s]是正则括号序列, 如果A和B是正则括号序列,则AB是正则括号序列。 没有其他序列是正则括号序列。 例如,下列都是正则括号序列: (), [], (()), () 阅读全文
posted @ 2019-07-16 14:02 prestige 阅读(339) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 给你一个字符串,里面只包含"(",")","[","]"四种符号,请问你需要至少添加多少个括号才能使这些括号匹配起来。 如: []是匹配的 ([])[]是匹配的 ((]是不匹配的 ([)]是不匹配的 【输入描述】: 第一行输入一个正整数N,表示测试数据组数(Ni时f[i 阅读全文
posted @ 2019-07-16 14:02 prestige 阅读(149) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P1040 cpp 本题即一个在树上做的区间dp,只不过中间枚举的断点k即为当前dp到的树的根节点,然后将当前区间分为两段,即为树上的左子树和右子树,不过要注意这里的k可以取到端点值,即k的取值范围为[i,j]因为一棵 阅读全文
posted @ 2019-07-16 13:50 prestige 阅读(152) 评论(0) 推荐(0)
摘要: ```cpp Description 在一个操场上一排地摆放着N堆石子。现要将石子有次序地合并成一堆。规定每次只能选相邻的2堆石子合并成新的一堆,并将新的一堆石子数记为该次合并的得分。 试设计一个程序,计算出将N堆石子合并成一堆的最小得分。 Input 第一行为一个正整数N (2≤N≤100); 以 阅读全文
posted @ 2019-07-16 13:49 prestige 阅读(216) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P1063 cpp 本题应先将数组拓宽一倍,这样就实现了环,之后枚举起始端点和区间长度,这样就能够算出结束端点,再利用转移方程f[l][r]=max(f[l][r],f[l][j]+f[j+1][r]+a[l] a[j 阅读全文
posted @ 2019-07-16 13:49 prestige 阅读(86) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P2782 阅读全文
posted @ 2019-07-16 13:48 prestige 阅读(178) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P1108 阅读全文
posted @ 2019-07-16 13:48 prestige 阅读(222) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P1510 阅读全文
posted @ 2019-07-16 13:47 prestige 阅读(101) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P1052 cpp dp方程很好推:f[i]=min(f[i],f[i j])+stone[i]; 但是要离散化,即将中间的距离mod 2520(1~10的最小公倍数) Code: include include us 阅读全文
posted @ 2019-07-16 13:46 prestige 阅读(91) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P1896 cpp 经典的状压dp,dp方程:f[i][j][k]+=f[i 1][j num[k]][l]; 还有位运算的判断也很重要 Code: include include include include in 阅读全文
posted @ 2019-07-16 13:46 prestige 阅读(134) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 学校里有一个水房,水房里一共装有m 个龙头可供同学们打开水,每个龙头每秒钟的供水量相等,均为1。 现在有n 名同学准备接水,他们的初始接水顺序已经确定。将这些同学按接水顺序从1到n 编号,i 号同学的接水量为wi。接水开始时,1 到m 号同学各占一个水龙头,并同时打开水 阅读全文
posted @ 2019-07-16 13:44 prestige 阅读(193) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P1801 阅读全文
posted @ 2019-07-16 13:44 prestige 阅读(172) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P1631 cpp 本题的n²个和为 A[1]+B[1] include include include include include include include using namespace std; con 阅读全文
posted @ 2019-07-16 13:43 prestige 阅读(123) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P1168 阅读全文
posted @ 2019-07-16 13:43 prestige 阅读(179) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P1090 cpp 先把初始果子放进优先队列维护,再将合并后的果子也扔进堆即可。 Code: include include include include include include include includ 阅读全文
posted @ 2019-07-16 13:42 prestige 阅读(134) 评论(0) 推荐(0)
摘要: ```cpp // 初始化n个元素 void init(int n) { for(int i=0;i 阅读全文
posted @ 2019-07-16 13:41 prestige 阅读(267) 评论(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 阅读(125) 评论(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 阅读(215) 评论(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 阅读(71) 评论(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 阅读(142) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-07-16 13:35 prestige 阅读(135) 评论(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 阅读(117) 评论(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 阅读(230) 评论(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 阅读(124) 评论(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 阅读(1236) 评论(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 阅读(126) 评论(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 阅读(503) 评论(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 阅读(111) 评论(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 阅读(408) 评论(0) 推荐(0)
摘要: ```cpp memset(isprime,1,sizeof(isprime)); isprime[1]=false; for(int i=2;i 阅读全文
posted @ 2019-07-16 13:29 prestige 阅读(407) 评论(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 阅读(112) 评论(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 阅读(86) 评论(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 阅读(476) 评论(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 阅读(87) 评论(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 阅读(84) 评论(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 阅读(174) 评论(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 阅读(106) 评论(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 阅读(146) 评论(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 阅读(105) 评论(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 阅读(158) 评论(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 阅读(137) 评论(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 阅读(1130) 评论(0) 推荐(2)
摘要: ```cpp 归并(Merge)排序法是将两个(或两个以上)有序表合并成一个新的有序表,即把待排序序列分为若干个子序列,每个子序列是有序的。然后再把有序子序列合并为整体有序序列。 目 录 1归并排序 2归并操作 3算法描述 4比较 5用途 5.1 排序 5.2 求逆序对数 6示例代码 6.1 归并排 阅读全文
posted @ 2019-07-16 13:05 prestige 阅读(236) 评论(0) 推荐(0)
摘要: ```cpp 一、定义 图的割点 一个无向连接图中,如果删除某个顶点后,图不再连同(即任意两点之间不能互相到达) ,称这样的顶点为割点 或:某个点是割点当且仅当删除该点和与该点相关联的边后图变得不连通。 图的割边/桥: 一个无向连通图中,如果删除某条边后,图不再连通,这条边就为割边。 或:某条边是割边当且仅当删除该边后图变的不连通。 二. 求割点,桥 使用dfs(深搜)来求割点和桥。先... 阅读全文
posted @ 2019-07-16 13:02 prestige 阅读(348) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-07-16 13:00 prestige 阅读(94) 评论(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 阅读(117) 评论(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 阅读(98) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 停电,漆黑的夜晚。 ACM + +是一家电力公司。该公司拥有数个发电厂,每一个供应一个小面积,这些发电厂给这个公司带来了很多的麻烦,在某些地区没有足够的电力,而在其他地区却有大量的盈余。 ACM ++因此决定将一些发电厂连接成一个网络。当然第一阶段,没有必要将所有的发电 阅读全文
posted @ 2019-07-16 12:47 prestige 阅读(138) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 蒟蒻刚刚学了点图论,现在他面对一张无向连通图,他想问你: 最少添加多少条边,使得任意两点之间有两条无公共边的路(可以有公共点)。 【输入描述】: 第一行n,m,n个点(编号1 n)m条边; 接下来m行,每行u,v; 表示u到v之间有一条无向边(可能重复描述一条边); 【 阅读全文
posted @ 2019-07-16 12:45 prestige 阅读(223) 评论(0) 推荐(0)
摘要: 题面:https://www.luogu.org/problemnew/show/P2746 cpp 对于子任务A,求需要给多少个学校发软件,即为求有多少个入度为0的点 因为对于对于每个入度不为0的点一定可以从一个其他点走到。 对于子任务B,求入度为0的点个数与出度为0的点个数的最大值,需要添多少条 阅读全文
posted @ 2019-07-16 12:44 prestige 阅读(151) 评论(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 阅读(200) 评论(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 阅读(139) 评论(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 阅读(156) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 每天,农夫约翰的N头奶牛总是按同一顺序排好队,有一天,约翰决定让一些牛玩一场飞盘游戏(Ultimate Frisbee),他决定在队列里选择一群位置连续的奶牛进行比赛,为了避免比赛结果过于悬殊,要求挑出的奶牛身高不要相差太大。 约翰准备了Q组奶牛选择,并告诉你所有奶牛的 阅读全文
posted @ 2019-07-16 12:38 prestige 阅读(129) 评论(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 阅读(233) 评论(0) 推荐(0)
摘要: ```cpp include include include include include include include using namespace std; const int N=1000005,M=25; int n,m,a[N],f[N][M]; int query(int L,in 阅读全文
posted @ 2019-07-16 12:34 prestige 阅读(120) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 给你一个长度为 n 的整数序列 {A1,A2,⋯,An},要求从中找出一段连续的长度不超过 m 的子序列,使得这个序列的和最大。 【输入描述】: 第一行为两个整数 n,m; 第二行为 n 个用空格分开的整数序列,每个数的绝对值都小于100。 【输出描述】: 仅一个整数, 阅读全文
posted @ 2019-07-16 12:32 prestige 阅读(330) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 给定一个长度为n的数列a,再给定一个长度为k的滑动窗口,从第一个数字开始依次框定k个数字,求每次框定的数字中的最大值和最小值,依次输出所有的这些值。下面有一个例子数组是 [1 3 1 3 5 6 7] , k 是3: 窗口位置 窗口中的最小值 窗口中的最大值 [1 3 -1] -3 5 3 6 7 ... 阅读全文
posted @ 2019-07-16 12:29 prestige 阅读(155) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 有n 个盘子。盘子被生产出来后,被按照某种顺序摞在一起。初始盘堆中如果一个盘子比所有它上面的盘子都大,那么它是安全的,否则它是危险的。称初始盘堆为A,另外有一个开始为空的盘堆 B。为了掩盖失误,生产商会对盘子序列做一些“处理”,每次进行以下操作中的一个:(1)将A 最上 阅读全文
posted @ 2019-07-16 12:26 prestige 阅读(126) 评论(0) 推荐(0)
摘要: ```cpp 【题目描述】: 地面上从左到右并排紧挨着摆放多个矩形,已知这此矩形的底边宽度都为1,高度不完全相等。求在这些矩形包括的范围内能得到的面积最大的矩形,打印出该面积。所求矩形可以横跨多个矩形,但不能超出原有矩形所确定的范围。 如 n = 7, 序列为2 1 4 5 1 3 3 _ _ ... 阅读全文
posted @ 2019-07-16 12:02 prestige 阅读(163) 评论(0) 推荐(0)