随笔分类 -  网络赛

摘要:给一颗树,其中树中有一些红色的点,每个点到距离它最近的祖先红点的距离称为它的距离。 每次给一个点子集,可以选择把树中任意一个点变为红色,问怎样让子集里的点的距离最大值最小。 当只有两个点时,肯定是先找到他们的 lca 然后先判断将 lca 染红是否可以让最大的距离变小,如果有一个点的祖先红点在 lc 阅读全文
posted @ 2018-09-17 14:53 LMissher 阅读(365) 评论(0) 推荐(0)
摘要:AC自动机上搞矩阵快速幂。 #include<cstdio> #include<cstring> #include<queue> #include<algorithm> #include<map> using namespace std; const int Nmax=207; const int 阅读全文
posted @ 2018-09-16 09:41 LMissher 阅读(195) 评论(0) 推荐(0)
摘要:一个背包dp。 //#define test #include<bits/stdc++.h> using namespace std; const int Nmax=1e4+7; const int Vmax=1e4; typedef long long ll; const ll mod=1e9+7 阅读全文
posted @ 2018-09-16 09:40 LMissher 阅读(189) 评论(0) 推荐(0)
摘要:不知道题意,队友用java大数+二分过了? import java.util.Arrays; import java.util.Scanner; import java.io.*; import java.math.*; public class Main { static boolean chec 阅读全文
posted @ 2018-09-16 09:39 LMissher 阅读(194) 评论(0) 推荐(0)
摘要:求一个串中出现次数在[L,R]区间里的子串一共有多少个,后缀数组用出现次数>=L的个数减去出现次数>R的个数就是答案。 //#define test #include<bits/stdc++.h> using namespace std; const int Nmax=250007; const i 阅读全文
posted @ 2018-09-16 09:37 LMissher 阅读(243) 评论(0) 推荐(0)
摘要:water #include <bits/stdc++.h> using namespace std; int n,a,b,c; int main(){ while(~scanf("%d%d%d",&a,&b,&c)){ int ans=a*b*c; if(ans%2==0) printf("Yes 阅读全文
posted @ 2018-09-16 09:37 LMissher 阅读(131) 评论(0) 推荐(0)
摘要:欧拉降幂求(A^B)%C,其中B超大。 //#define test #include<bits/stdc++.h> using namespace std; const int Nmax=1e6+7; typedef long long ll; const ll mod = 1e9+7; char 阅读全文
posted @ 2018-09-16 09:34 LMissher 阅读(154) 评论(0) 推荐(0)
摘要:区间k覆盖费用流模板题。 离散化后让每个数字最多可用k次即可,源点向起点连边,终点向汇点连边,第i个点向第i+1个点连边,容量都为k,费用为0。 对于给的左闭右开区间,区间左端点向右端点连边,容量为1,费用为-val。 #include <bits/stdc++.h> using namespace 阅读全文
posted @ 2018-09-16 09:32 LMissher 阅读(166) 评论(0) 推荐(0)
摘要:区间更新加法与乘法,x取反是2^64-x-1,由于取模所以取反变成-x-1,就区间*-1再-1就可以了,最后区间询问求和。 #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define fi first #def 阅读全文
posted @ 2018-09-16 09:29 LMissher 阅读(224) 评论(0) 推荐(0)
摘要:dp维护一下最大值与最小值,注意边界情况的判定。 #include <iostream> #include <cstring> using namespace std; const long long inf = (long long)1e18+(long long)9; long long dp[ 阅读全文
posted @ 2018-09-16 09:28 LMissher 阅读(303) 评论(0) 推荐(0)
摘要:water #include <bits/stdc++.h> #include <unordered_set> #include <unordered_map> #define pb push_back #define mp make_pair #define x first #define y s 阅读全文
posted @ 2018-09-16 09:27 LMissher 阅读(190) 评论(0) 推荐(0)
摘要:有三种操作,第一种把+v,第二种-v,第三种*-1。现在先手的会让最后的值最大,后手的让最后的值最小。 所有操作后的值在区间[-100,100]内,问最后的值是多少。 因为所有的值只有200种可能性,所有每个操作之后最多可能也只有200种值。 那么记忆化搜索把每个操作之后的状态存下来就避免了暴力搜索 阅读全文
posted @ 2018-09-10 14:34 LMissher 阅读(172) 评论(0) 推荐(0)
摘要:给n个以原点为左下角的矩形,求最后图形右边界和上边界的周长和。 从后向前放矩形,线段树维护每个点左边最近的距离及下面最近的距离即可。 #include <bits/stdc++.h> #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #def 阅读全文
posted @ 2018-09-09 21:58 LMissher 阅读(220) 评论(0) 推荐(0)
摘要:求出最大生成树之后求LCA即可。 #pragma comment(linker, "/STACK:1024000000,1024000000") #include <iostream> #include <stdio.h> #include <iomanip> #include <algorithm 阅读全文
posted @ 2018-09-09 21:55 LMissher 阅读(163) 评论(0) 推荐(0)
摘要:正式比赛线段树第一题。 很裸的线段树,维护一个区间和及答案,答案由左右两边的答案及左边的区间和乘上右边的长度可得。 求答案的时候要线段树合并。 #include <bits/stdc++.h> #include <unordered_set> #include <unordered_map> #de 阅读全文
posted @ 2018-09-09 21:54 LMissher 阅读(258) 评论(0) 推荐(0)
摘要:维护每个字符出现的次数即可 #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define mem(x) memset(x,0,sizeof(x)) #define mem1(x) memset(x,-1,size 阅读全文
posted @ 2018-09-09 21:51 LMissher 阅读(115) 评论(0) 推荐(0)
摘要:签到题~ #include <iostream> using namespace std; inline int Abs(int x) { return (x>0?x:(-x)); } int main() { char s[100007]; char ans[300007]; char se,c; 阅读全文
posted @ 2018-09-09 21:50 LMissher 阅读(150) 评论(0) 推荐(0)
摘要:给一颗树,两种操作,一种把同一层的点权值加上v,另一种求一点下的子树权值和。 按层数中点个数分块,小块直接暴力把所有点用bit更新,大块把层的值存下来。 询问的时候子树权值和为bit中的值以及其下面的点在大块中的值,下面中的点在大块中的值用二分实现。 #include <bits/stdc++.h> 阅读全文
posted @ 2018-09-08 23:28 LMissher 阅读(189) 评论(0) 推荐(0)
摘要:容斥+状压 #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1e9+7; #include<vector> //const int MAX = 110; const int N = 1 阅读全文
posted @ 2018-09-08 22:21 LMissher 阅读(166) 评论(0) 推荐(0)
摘要:正解应该是上下界网络流模板题,被队友用贪心水过去了。 #include <bits/stdc++.h> #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define up rt,rt<<1,rt<<1|1 #define mem(x) m 阅读全文
posted @ 2018-09-08 22:20 LMissher 阅读(190) 评论(0) 推荐(0)