![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
模板
chr1st0pher
Dancer on the keyboard
展开
-
BZOJ1047 [HAOI2007]理想的正方形(二维单调队列)
Description 有一个ab的整数组成的矩阵,现请你从中找出一个nn的正方形区域,使得该区域所有数中的最大值和最小值的差最小。Input 第一行为3个整数,分别表示a,b,n的值第二行至第a+1行每行为b个非负整数,表示矩阵中相应位置上的数。每行相邻两数之间用一空格分隔。100%的数据2<=a,b<=1000,n<=a,n<=b,n<=1000...原创 2020-06-11 13:51:50 · 197 阅读 · 1 评论 -
BZOJ 2243 [SDOI2011] 染色(树剖 + 线段树)
Description给定一棵有nnn个节点的无根树和mmm个操作,操作有2类:1、将节点aaa到节点bbb路径上所有点都染成颜色ccc;2、询问节点aaa到节点bbb路径上的颜色段数量(连续相同颜色被认为是同一段),如“112221112221112221”由3段组成:“111111”、“222222222”和“111”。请你写一个程序依次完成这mmm个操作。Input第一行包含2个整数nnn和mmm,分别表示节点数和操作数;第二行包含nnn个正整数表示nnn个节点的初始颜色下面 行每行原创 2020-07-09 16:05:45 · 116 阅读 · 0 评论 -
Gym 102218G. Generating Problems (LICS)
DescriptionAbraham and Filiberto have been arguing a lot during the last two months. They haven’t decided which problems are going to be used in the 11th edition of the Annual Programming Contest.As the date of the competition is coming soon, they both p原创 2020-08-10 23:17:55 · 72 阅读 · 0 评论 -
求乘法逆元方法总结
目录简介扩展欧几里得法IdeaCode快速幂法IdeaCode线性求[1,n]逆元IdeaCode线性求任意n个数的逆元IdeaCode简介若有线性同余方程 ax≡1(mod p)ax\equiv 1\left( mod~p\right)ax≡1(mod p),则称 xxx 为 aaa 在模 ppp 意义下的逆元,记作 a−1a^{-1}a−1扩展欧几里得法Idea原方程 ax≡1(mod p)ax\equiv 1\left( mod~p\right)ax≡1(mod原创 2020-08-04 21:40:21 · 240 阅读 · 1 评论 -
Codeforces 343D. Water Tree (树链剖分 + 区间染色)
DescriptionMad scientist Mike has constructed a rooted tree, which consists of n vertices. Each vertex is a reservoir which can be either empty or filled with water.The vertices of the tree are numbered from 1 to n with the root at vertex 1. For each ver原创 2020-07-08 21:31:42 · 162 阅读 · 0 评论 -
Codeforces 159D. Palindrome pairs (Manacher +DP)
DescriptionYou are given a non-empty string s consisting of lowercase letters. Find the number of pairs of non-overlapping palindromic substrings of this string.In a more formal way, you have to find the quantity of tuples (a, b, x, y) such that 1 ≤ a ≤原创 2020-07-15 23:41:33 · 331 阅读 · 0 评论 -
Gym - 102174G 神圣的 F2 连接着我们 (线段树优化建图 + 多源最短路)
Description小白非常喜欢玩 “县际争霸” 这款游戏,虽然他的技术并不容乐观。“县际争霸” 的地图共有两个县,每个县里各有 nnn 个据点。同一个县之间的据点是互不连通的,两个县之间的据点也是互不连通的。小白的 ppp 个战斗单位在第一个县的第 x1,x2,⋯,xpx_1,x_2,⋯,x_px1,x2,⋯,xp 个据点中,而对手的 qqq 个建筑单位在第二个县第 y1,y2,⋯,yqy_1,y_2,⋯,y_qy1,y2,⋯,yq 个据点中。为了发起进攻,小白建造了很多的 “折跃棱镜”原创 2020-07-13 10:37:31 · 286 阅读 · 0 评论 -
BZOJ1040 骑士(基环树DP)
Description Z国的骑士团是一个很有势力的组织,帮会中汇聚了来自各地的精英。他们劫富济贫,惩恶扬善,受到社会各界的赞扬。最近发生了一件可怕的事情,邪恶的Y国发动了一场针对Z国的侵略战争。战火绵延五百里,在和平环境中安逸了数百年的Z国又怎能抵挡的住Y国的军队。于是人们把所有的希望都寄托在了骑士团的身上,就像期待有一个真龙天子的降生,带领正义打败邪恶。骑士团是肯定具有打败邪恶势力的能力的,但是骑士们互相之间往往有一些矛盾。每个骑士都有且仅有一个自己最厌恶的骑士(当然不是他自己),他是绝对不原创 2020-06-10 21:53:48 · 324 阅读 · 0 评论 -
Gym - 102448F Finally, christmas! (扫描线)
DescriptionThe christmas spirit is taking over the city of Arcoverde! In honor of this special day, the mayor of this renowned metropolis decided to decorate all of the city’s front view. To do this, he asked his engineer friends Icaro and Cortizo how muc原创 2020-07-03 19:58:46 · 176 阅读 · 0 评论 -
点分治(模板)
模板题:洛谷P3806题目描述给定一棵有 nnn 个点的树,询问树上距离为 kkk 的点对是否存在。输入格式第一行两个数 nnn,mmm。第 222 到第 nnn 行,每行三个整数 u,v,wu, v, wu,v,w,代表树上存在一条连接 uuu 和 vvv 边权为 www 的路径。接下来 mmm 行,每行一个整数 kkk,代表一次询问。输出格式对于每次询问输出一行一个字符串代表答案,存在输出 AYE,否则输出 NAY。数据范围1≤n≤1e41 \leq n \leq 1e41≤n≤1原创 2020-06-24 02:42:50 · 130 阅读 · 0 评论 -
求树的直径(模板)
两次BFS:第一次以任意点为根,找到距离根最远的点x第二次以x为根,找到离x最远的点yx ~ y 即为树的直径Code_Example:struct edge{ int v,w;};struct node{ int u,w;};vector<edge>e[MX];int dis;int bfs(int s){ int res = 0; dis = 0; bool vis[MX];clr(vis,false); queue<node>q;q.pus原创 2020-06-10 18:19:59 · 187 阅读 · 0 评论 -
高斯消元(模板)
模板题:洛谷P3389高斯消元法Code:int n;double a[MX][MX];double ans[MX];void guess(){ for(int i = 1;i <= n;++i){ int r = i; for(int j = i + 1;j <= n;++j){ if(fabs(a[r][i]) < fabs(a[j][i])) r = j; } if(fabs(a[r][i]) < eps){ printf("No S原创 2020-06-07 19:17:01 · 172 阅读 · 0 评论