自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(44)
  • 收藏
  • 关注

原创 牛客网-白兔的字符串(字符串哈希)

解题思路:好像使用map会超时,所以采用链式哈希。#include<iostream>#include<cstdio>#include<queue>#include<cstring>#include<algorithm>using namespace std;const int maxn = 2000005;c...

2019-09-11 23:25:27 256

原创 牛客网-子串

题目链接:https://ac.nowcoder.com/acm/problem/13253解题思路:模拟出每一个进制形成的字符串然后KMP就可以了!好像用string直接find也行#include<iostream>#include<cstdio>#include<queue>#include<cstring>#in...

2019-09-11 21:14:00 271

原创 CF-1183H Subsequences (hard version)(DP)

题目链接:https://codeforc.es/problemset/problem/1183/H题目大意:给你一个字符串,删去一个字符需要花费1个价值,删去字符后就可以得到新的子串,要使得子串集合的大小为k,最小的代价是多少。我们定义dp[i][len]为以第i个字母为子串最后一个字符,长度为len的子串有多少个。每一个字母由上一个字母转移得到。如:如果第i个字符为‘y’...

2019-09-10 21:58:14 177

原创 CF-1198D (二维DP)

题目链接:https://codeforc.es/problemset/problem/1198/D给你一个n*n(n<51)的棋盘,棋盘上有黑格有白格,每次可以花费max(w,h)的价值,将一个w*h的矩阵涂白,问你将这个棋盘涂白的最小花费是多少?解题思路:定义dp[x1][y1][x2][y2]为将(x1,y1)-(x2,y2)为对角线的矩阵染成白色的最小花费,这样子不断分解...

2019-09-10 18:25:24 224

原创 CF 1217E(线段树)

题目链接https://codeforc.es/problemset/problem/1217/E题目大意:给你一个序列有两种操作:1 i x,修改第i个数为x;2 l, r 查询[l,r]区间内 不平衡子序列中元素和最小的那一个序列。一个序列不平衡的条件是,这个序列中所有数字加起来的和中有一个十进制位的数是序列中没有一个数出现的。如第一个序列是平衡的因为10...

2019-09-10 16:58:45 255

原创 P2764 最小路径覆盖问题(网络流)

输入 #1 11 121 21 31 42 53 64 75 86 97 108 119 1110 11输出 #1 1 4 7 10 112 5 83 6 93说明/提示1≤n≤150,1≤m≤6000网络流可求最小路径覆盖,算是模板题了先拆点,然后建超级源超级汇,超级源连所有拆点的左边的点,然后右边的点连超级汇,对应输入的边都从左到右去连边就...

2019-09-05 19:22:36 116

原创 CF-1207F Remainder Problem(分块)

题目:https://codeforces.com/problemset/problem/1207/F给你两种操作:1 x, y——对第x个数加y2 x, y—— 计算[1,500000]中模x等于y的那些位的和思路:数据大小500000,开根号为710,所以如果模的数超过710,那么循环节就大于710,时间复杂度是根号n的,如果模数小于710我们就先预处理出来就好了。...

2019-08-30 15:05:30 157

原创 P2590 树的统计(树链剖分+线段树)

题目描述一棵树上有n个节点,编号分别为1到n,每个节点都有一个权值w。我们将以下面的形式来要求你对这棵树完成一些操作:I. CHANGE u t : 把结点u的权值改为tII. QMAX u v: 询问从点u到点v的路径上的节点的最大权值III. QSUM u v: 询问从点u到点v的路径上的节点的权值和注意:从点u到点v的路径上的节点包括u和v本身输入格式输入文件...

2019-08-28 21:48:52 223

原创 P2633 Count on a tree 树上主席树+LCA

题目描述给定一棵N个节点的树,每个点有一个权值,对于M个询问(u,v,k),你需要回答u xor lastans和v这两个节点间第K小的点权。其中lastans是上一个询问的答案,初始为0,即第一个询问的u是明文。输入格式第一行两个整数N,M。第二行有N个整数,其中第i个整数表示点i的权值。后面N-1行每行两个整数(x,y),表示点x到点y有一条边。最后M行每行两个整数(u...

2019-08-28 20:27:34 147

原创 P2048 超级钢琴(RMQ+优先队列)

题目描述小Z是一个小有名气的钢琴家,最近C博士送给了小Z一架超级钢琴,小Z希望能够用这架钢琴创作出世界上最美妙的音乐。这架超级钢琴可以弹奏出n个音符,编号为1至n。第i个音符的美妙度为Ai,其中Ai可正可负。一个“超级和弦”由若干个编号连续的音符组成,包含的音符个数不少于L且不多于R。我们定义超级和弦的美妙度为其包含的所有音符的美妙度之和。两个超级和弦被认为是相同的,当且仅当这两个超级...

2019-08-27 21:47:22 108

原创 P4570 元素 (线性基)

题目描述相传,在远古时期,位于西方大陆的 Magic Land 上,人们已经掌握了用魔法矿石炼制法杖的技术。那时人们就认识到,一个法杖的法力取决于使用的矿石。一般地,矿石越多则法力越强,但物极必反:有时,人们为了获取更强的法力而使用了很多矿石,却在炼制过程中发现魔法矿石全部消失了,从而无法炼制出法杖,这个现象被称为“魔法抵消” 。特别地,如果在炼制过程中使用超过一块同一种矿石,那么一定会发...

2019-08-26 15:06:07 86

原创 POJ - 2187 Beauty Contest(旋转卡壳求最远点对)

题目:Bessie, Farmer John's prize cow, has just won first place in a bovine beauty contest, earning the title 'Miss Cow World'. As a result, Bessie will make a tour of N (2 <= N <= 50,000) far...

2019-08-25 21:37:12 308

原创 POJ - 3525 Most Distant Point from the Sea (半平面交+二分)

题目:The main land of Japan called Honshu is an island surrounded by the sea. In such an island, it is natural to ask a question: “Where is the most distant point from the sea?” The answer to this que...

2019-08-21 16:15:37 164

原创 POJ-3355 Rotating Scoreboard (多边形内核)

题目:This year, ACM/ICPC World finals will be held in a hall in form of a simple polygon. The coaches and spectators are seated along the edges of the polygon. We want to place a rotating scoreboard s...

2019-08-21 14:58:14 148

原创 POJ - 3348 Cow(凸包面积)

问题:Your friend to the south is interested in building fences and turning plowshares into swords. In order to help with his overseas adventure, they are forced to save money on buying fence posts by ...

2019-08-21 04:10:18 122

原创 POJ 1228 Grandpa's Estate(稳定凸包)

题目:Being the only living descendant of his grandfather, Kamran the Believer inherited all of the grandpa's belongings. The most valuable one was a piece of convex polygon shaped farm in the grand...

2019-08-21 03:53:31 116

原创 POJ-1873 The Fortified Forest(凸包问题)

题目:Once upon a time, in a faraway land, there lived a king. This king owned a small collection of rare and valuable trees, which had been gathered by his ancestors on their travels. To protect his t...

2019-08-21 02:54:01 272

原创 POJ-2007 Scrambled Polygon(凸包)

题目:A closed polygon is a figure bounded by a finite number of line segments. The intersections of the bounding line segments are called the vertices of the polygon. When one starts at any vertex ...

2019-08-21 01:48:47 132

原创 POJ 1113 Wall (凸包)

题目:Once upon a time there was a greedy King who ordered his chief Architect to build a wall around the King's castle. The King was so greedy, that he would not listen to his Architect's proposals to...

2019-08-20 16:23:18 71

原创 HDU-2829 Lawrence(二维斜率优化DP)

题目:T. E. Lawrence was a controversial figure during World War I. He was a British officer who served in the Arabian theater and led a group of Arab nationals in guerilla strikes against the Ottoman ...

2019-08-19 16:33:32 155

原创 HDU-3507 Print Article(斜率优化DP)

题目:Zero has an old printer that doesn't work well sometimes. As it is antique, he still like to use it to print articles. But it is too old to work for a long time and it will certainly wear and tea...

2019-08-19 13:51:54 318

原创 HDU-6638 Snowy Smile 区间最大子段和

题目:There arennpirate chests buried in Byteland, labeled by1,2,…,n1,2,…,n. Theii-th chest's location is(xi,yi)(xi,yi), and its value iswiwi,wiwican be negative since the pirate can add some p...

2019-08-16 18:33:56 296

原创 牛客多校第七场 H-Pair(数位DP)

题目描述Given three integers A,B,C Count the number of pairs <x ,y> (with 1<=x<=Aand1<=y<=B)such that at least one of the following is true:- (x & y) > C- (x ^y) <C(...

2019-08-13 17:22:49 293

原创 洛谷P3834-主席树(模板题)

题目背景这是个非常经典的主席树入门题——静态区间第K小数据已经过加强,请使用主席树。同时请注意常数优化题目描述如题,给定N个整数构成的序列,将对于指定的闭区间查询其区间内的第K小值。输入格式第一行包含两个正整数N、M,分别表示序列的长度和查询的个数。第二行包含N个整数,表示这个序列各项的数字。接下来M行每行包含三个整数l, r, kl,r,k, 表示查询区间[l,...

2019-08-11 15:31:07 167

原创 HDU-6604 Blow up the city (支配树)

题目:Country A and B are at war. Country A needs to organize transport teams to deliver supplies toward some command center cities.In order to ensure the delivery works efficiently, all the roads in...

2019-07-31 22:16:55 471

原创 洛谷 P2597 灾难(支配树)

题目描述阿米巴是小强的好朋友。阿米巴和小强在草原上捉蚂蚱。小强突然想,如果蚂蚱被他们捉灭绝了,那么吃蚂蚱的小鸟就会饿死,而捕食小鸟的猛禽也会跟着灭绝,从而引发一系列的生态灾难。学过生物的阿米巴告诉小强,草原是一个极其稳定的生态系统。如果蚂蚱灭绝了,小鸟照样可以吃别的虫子,所以一个物种的灭绝并不一定会引发重大的灾难。我们现在从专业一点的角度来看这个问题。我们用一种叫做食物网的有向图来...

2019-07-31 20:18:01 322

原创 HDU-6609 Find the answer (权值线段树)

题目:Given a sequence of n integers called W and an integer m. For each i (1 <= i <= n), you can choose some elementsWkWk(1 <= k < i), and change them to zero to make∑ij=1∑j=1i...

2019-07-31 09:17:04 292

原创 基础计算几何模板

#include <iostream>#include<cstdio>#include<cstring>#include<cmath>using namespace std;const double eps = 1e-8;const double PI = acos(-1.0);//对于浮点数的,><=0的判断。in...

2019-07-29 22:21:56 118

原创 POJ-1269 Intersecting Lines (两条直线的位置关系)

题目:We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three ways: 1) no intersection because they are parallel, 2) inte...

2019-07-28 22:54:08 109

原创 POJ-3304 Segments (判断是否存在一条直线交所以线段)

问题:Givennsegments in the two dimensional space, write a program, which determines if there exists a line such that after projecting these segments on it, all projected segments have at least one p...

2019-07-28 22:16:11 133

原创 POJ—2318 TOYS(叉积判断点和直线关系)

题目:Calculate the number of toys that land in each bin of a partitioned toy box.Mom and dad have a problem - their child John never puts his toys away when he is finished playing with them. They ga...

2019-07-28 20:59:03 365

原创 poj-1155 TELE (树形分组背包)

题目:A TV-network plans to broadcast an important football match. Their network of transmitters and users can be represented as a tree. The root of the tree is a transmitter that emits the football ma...

2019-07-22 21:53:34 172

原创 CF-219D Choosing Capital for Treeland

题目:The country Treeland consists ofncities, some pairs of them are connected withunidirectionalroads. Overall there aren - 1roads in the country. We know that if we don't take the direction of...

2019-07-22 16:32:54 175

原创 POJ3162-Walking Race

题目:flymouse’s sister wc is very capable at sports and her favorite event is walking race. Chasing after the championship in an important competition, she comes to a training center to attend a train...

2019-07-22 15:08:01 98

原创 Tree

题目:Give a tree with n vertices,each edge has a length(positive integer less than 1001).Define dist(u,v)=The min distance between node u and v.Give an integer k,for every pair (u,v) of vertices is...

2019-07-21 09:40:03 174

原创 树分治

什么是分治算法:分治算法的思想是将一个规模为N的问题分解为K个规模的较小的子问题,这些子问题相互独立且与原问题性质相同。求出这些问题的解后再将这些子问题的解合并,就可以得到原问题的解。例如快速排序和归并排序。所谓树分治,就是在树形结构上的一种分治问题,主要操作是去除原本树中的某些对象,使得原树被分解成若干个互不相交的部分,由此可以解决许多以路径为询问对象的问题。树分治分为以下两种...

2019-07-16 20:46:26 1045

原创 Computer

题目:A school bought the first computer some time ago(so this computer's id is 1). During the recent years the school bought N-1 new computers. Each new computer was connected to one of settled earlie...

2019-07-16 11:29:47 115

原创 Anniversary party

题目:There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor relation forms...

2019-07-16 02:55:31 157

原创 数据结构——莫队算法

莫队算法是一种用来解决大量的区间询问的暴力算法。问题引入:洛谷[P2709] : 小B有一个序列,包含N个1~K的整数, 一共有M个询问求∑i=lrcnt[vis[i]]2\displaystyle\sum_{i=l}^{r} cnt[vis[i]]^2i=l∑r​cnt[vis[i]]2,也就是区间内所有出现的数的个数的平方和。样例输入: ...

2019-05-19 22:27:10 200

原创 KMP模板

KMP主要分为两个部分1.首先对于模式串,获取next[],next[]的意义在于,对于一个位置i,如果它与主串失配了,我的模式串要回退到哪里去,也就是对于一个位置i,找到前面的一个最大的j,使得(j的前缀)刚好也是(i前缀的后缀)。然后我的模板是先获取i-1和j-1的,这样才知道如何回退,知道后就再next[++i] = ++j;2.KMP主算法,两个变量 i , j 记录主串位置的模式...

2018-11-11 16:32:37 81

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除