自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 CF1324 Maximum White Subtree 【换根dp】

You are given a tree consisting of????nvertices. A tree is a connected undirected graph with????−1n−1edges. Each vertex????vof this tree has a color assigned to it (????????=1av=1if the vertex????vis white and...

2020-03-14 14:28:00 352 1

原创 Leetcode 5346 二叉树中的列表【dfs暴力】

给你一棵以root为根的二叉树和一个head为第一个节点的链表。如果在二叉树中,存在一条一直向下的路径,且每个点的数值恰好一一对应以head为首的链表中每个节点的值,那么请你返回 True ,否则返回 False 。一直向下的路径的意思是:从树中某个节点开始,一直连续向下的路径。示例 1:输入:head = [4,2,8], root = [1,4,4,null,...

2020-03-01 21:22:46 202

原创 leetcode 7. 整数反转(不用long long)

给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。示例1:输入: 123输出: 321示例 2:输入: -123输出: -321示例 3:输入: 120输出: 21注意:假设我们的环境只能存储得下 32 位的有符号整数,则其数值范围为[−231,231− 1]。请根据这个假设,如果反转后整数溢出那么就返回 0。题目倒是很简单,但...

2019-11-29 13:49:44 223

原创 Leetcode 913. 猫和老鼠 【dp】【dfs剪枝】

两个玩家分别扮演猫(Cat)和老鼠(Mouse)在无向图上进行游戏,他们轮流行动。该图按下述规则给出:graph[a]是所有结点 b 的列表,使得 ab 是图的一条边。老鼠从结点 1 开始并率先出发,猫从结点 2 开始且随后出发,在结点 0 处有一个洞。在每个玩家的回合中,他们必须沿着与他们所在位置相吻合的图的一条边移动。例如,如果老鼠位于结点 1,那么它只能移动到graph[1]...

2019-11-07 21:50:17 300

原创 leetcode 795. 区间子数组个数

给定一个元素都是正整数的数组A,正整数 L以及R(L <= R)。求连续、非空且其中最大元素满足大于等于L小于等于R的子数组个数。例如 :输入:A = [2, 1, 4, 3]L = 2R = 3输出: 3解释: 满足条件的子数组: [2], [2, 1], [3].查找满足小于等于R,大于等于L的字数组可以转化为:小于等于R的字数组 - 小于L的字数组,...

2019-09-26 21:00:52 189

原创 leetcode 450. 删除二叉搜索树中的节点

给定一个二叉搜索树的根节点 root 和一个值 key,删除二叉搜索树中的key对应的节点,并保证二叉搜索树的性质不变。返回二叉搜索树(有可能被更新)的根节点的引用。一般来说,删除节点可分为两个步骤:首先找到需要删除的节点;如果找到了,删除它。说明: 要求算法时间复杂度为O(h),h 为树的高度。示例:root = [5,3,6,2,4,null,7]key = 3...

2019-09-14 20:06:33 254

原创 leetcode 715. Range 模块 【二叉搜索树】

Range 模块是跟踪数字范围的模块。你的任务是以一种有效的方式设计和实现以下接口。addRange(int left, int right) 添加半开区间[left, right),跟踪该区间中的每个实数。添加与当前跟踪的数字部分重叠的区间时,应当添加在区间[left, right)中尚未跟踪的任何数字到该区间中。queryRange(int left, int right)只有在...

2019-09-13 15:17:14 192

原创 leetcode 438. 找到字符串中所有字母异位词 【滑动窗口】

给定一个字符串s和一个非空字符串p,找到s中所有是p的字母异位词的子串,返回这些子串的起始索引。字符串只包含小写英文字母,并且字符串s和 p的长度都不超过 20100。说明:字母异位词指字母相同,但排列不同的字符串。不考虑答案输出的顺序。示例1:输入:s: "cbaebabacd" p: "abc"输出:[0, 6]解释:起始索引等于 0 的...

2019-09-10 20:58:34 104

原创 leetcode 850. 矩形面积 II 【矩形面积并】【线段树】【扫描线】

我们给出了一个(轴对齐的)矩形列表rectangles。 对于rectangle[i] = [x1, y1, x2, y2],其中(x1,y1)是矩形i左下角的坐标,(x2,y2)是该矩形右上角的坐标。找出平面中所有矩形叠加覆盖后的总面积。 由于答案可能太大,请返回它对 10 ^ 9 + 7 取模的结果。示例 1:输入:[[0,0,2,2],[1,0,2,3],[1,0,3,...

2019-09-07 14:14:00 730

原创 leetcode 6. Z 字形变换【模拟】

将一个给定字符串根据给定的行数,以从上往下、从左到右进行Z 字形排列。比如输入字符串为 "LEETCODEISHIRING"行数为 3 时,排列如下:L C I RE T O E S I I GE D H N之后,你的输出需要从左往右逐行读取,产生出一个新的字符串,比如:"LCIRETOESIIGEDHN"。请你实现这个将字符串进行指定行数变换的函数:...

2019-09-04 10:33:30 289

原创 leetcode 5. 最长回文子串 【马拉车】

给定一个字符串 s,找到 s 中最长的回文子串。你可以假设s 的最大长度为 1000。示例 1:输入: "babad"输出: "bab"注意: "aba" 也是一个有效答案。示例 2:输入: "cbbd"输出: "bb"来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/longest-palindromic-subst...

2019-09-03 20:17:10 170

原创 Codeforces Round #531 (Div. 3) D Balanced Ternary String【模拟】

You are given a string ss consisting of exactly nn characters, and each character is either '0', '1' or '2'. Such strings are called ternary strings.Your task is to replace minimum number of charact...

2019-01-14 13:03:00 267

原创 Codeforces Round #529 (Div. 3)F. Make It Connected 【最小生成树】

You are given an undirected graph consisting of nn vertices. A number is written on each vertex; the number on vertex ii is aiai. Initially there are no edges in the graph.You may add some edges to ...

2018-12-28 10:12:01 428

原创 Hrbust 1162 魔女 【dp】

魔女 Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 153(59 users) Total Accepted: 44(30 users) Rating:  Special Judge: No Description     平行世界是动...

2018-12-04 20:03:48 206

原创 Codeforces Round #524 (Div. 2) C Masha and two friends 【矩形交】

#include&lt;bits/stdc++.h&gt;using namespace std;#define ll long longint main(){ int N; for(cin &gt;&gt; N; N; N--){ ll n, m; ll x1, x2, x3, x4, y1, y2, y3, y4; cin...

2018-11-26 22:36:22 210

原创 HihoCoder 1054 滑动解锁 【dfs】

时间限制:2000ms单点时限:1000ms内存限制:256MB描述滑动解锁是智能手机一项常用的功能。你需要在3x3的点阵上,从任意一个点开始,反复移动到一个尚未经过的"相邻"的点。这些划过的点所组成的有向折线,如果与预设的折线在图案、方向上都一致,那么手机将解锁。两个点相邻当且仅当以这两个点为端点的线段上不存在尚未经过的点。此外,这条折线还需要至少经过4个点。为了描述方便,我...

2018-10-09 20:06:11 167

原创 Codeforces Round #514 (Div. 2) C. Sequence Transformation 【思维】【规律】

C. Sequence Transformationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call the following process a transformation of a...

2018-10-08 20:43:17 222

原创 Codeforces Round #513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2) D. Social Circles 【贪心】

D. Social Circlestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou invited nn guests to dinner! You plan to arrange one or mor...

2018-10-08 19:44:37 433

原创 Codeforces Round #514 (Div. 2) B. Forgery【模拟】

B. Forgerytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputStudent Andrey has been skipping physical education lessons for the wh...

2018-10-08 19:43:00 150

原创 ACM/ICPC 2018亚洲区预选赛北京赛站网络赛 A Saving Tang Monk II 【分层搜索】

时间限制:1000ms单点时限:1000ms内存限制:256MB描述《Journey to the West》(also 《Monkey》) is one of the Four Great Classical Novels of Chinese literature. It was written by Wu Cheng'en during the Ming Dynasty. I...

2018-09-27 19:46:36 173

原创 Technocup 2019 - Elimination Round 1 C Vasya and Golden Ticket 【水题】

C. Vasya and Golden Tickettime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently Vasya found a golden ticket — a sequence which...

2018-09-27 19:06:11 375

原创 Educational Codeforces Round 51 (Rated for Div. 2) C Vasya and Multisets 【水题】

C. Vasya and Multisetstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has a multiset ss consisting of nn integer numbers. V...

2018-09-21 21:18:17 586

原创 ACM-ICPC 2018 南京赛区网络预赛 G Lpl and Energy-saving Lamps 【线段树】

During tea-drinking, princess, amongst other things, asked why has such a good-natured and cute Dragon imprisoned Lpl in the Castle? Dragon smiled enigmatically and answered that it is a big secret. A...

2018-09-06 21:46:16 193

原创 2018 ACM-ICPC 2018 南京赛区网络预赛 L Magical Girl Haze 【分层最短路】

链接There are NN cities in the country, and MM directional roads from uu to v(1\le u, v\le n)v(1≤u,v≤n). Every road has a distance c_ici​. Haze is a Magical Girl that lives in City 11, she can choose ...

2018-09-02 19:57:40 386

原创 Uva 11992 Fast Matrix Operations 【线段树】【双标记pushdown】

#include&lt;bits/stdc++.h&gt;using namespace std;#define lson rt &lt;&lt; 1, l, mid#define rson rt &lt;&lt; 1 | 1, mid + 1, rconst int MAX = 1e5 + 7;const int INF = 0x3f3f3f3f;struct node{ ...

2018-08-28 22:17:30 146

原创 codeforces 138 C Mushroom Gnomes - 2 【线段树】【离散化】【概率】

C. Mushroom Gnomes - 2time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Natalia was walking in the woods when she met a lit...

2018-08-28 20:41:21 597

原创 HDU 4777 Rabbit Kingdom 【树状数组】

 Long long ago, there was an ancient rabbit kingdom in the forest. Every rabbit in this kingdom was not cute but totally pugnacious, so the kingdom was in chaos in season and out of season.   n rabbi...

2018-08-28 19:33:26 226

原创 POJ 2991 Crane 【线段树】【向量旋转】

ACM has bought a new crane (crane -- jeřáb) . The crane consists of n segments of various lengths, connected by flexible joints. The end of the i-th segment is joined to the beginning of the i + 1-th ...

2018-08-27 21:40:11 209

原创 HDU 6438 Buy and Resell 【贪心】【优先队列】【map】

Buy and ResellTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1353    Accepted Submission(s): 447 Problem DescriptionThe Power Cube is u...

2018-08-26 22:55:57 134

原创 codeforces Buy Low Sell High 【贪心】【优先队列】

E. Buy Low Sell Hightime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou can perfectly predict the price of a certain stock for t...

2018-08-26 22:26:10 395

原创 HDU 6447 YJJ's Salesman 【线段树】【dp】【离散化】

YJJ's SalesmanTime Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1109    Accepted Submission(s): 378 Problem DescriptionYJJ is a salesman w...

2018-08-26 21:13:18 189

原创 HDU 4521 小明系列问题——小明序列 【线段树】【lis】

大家都知道小明最喜欢研究跟序列有关的问题了,可是也就因为这样,小明几乎已经玩遍各种序列问题了。可怜的小明苦苦地在各大网站上寻找着新的序列问题,可是找来找去都是自己早已研究过的序列。小明想既然找不到,那就自己来发明一个新的序列问题吧!小明想啊想,终于想出了一个新的序列问题,他欣喜若狂,因为是自己想出来的,于是将其新序列问题命名为“小明序列”。   提起小明序列,他给出的定义是这样的:   ①首先...

2018-08-23 13:53:52 180

原创 codeforces 1027D Mouse Hunt 【并查集】【dfs】

D. Mouse Hunttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMedicine faculty of Berland State University has just finished thei...

2018-08-19 09:56:01 477

原创 codeforces 1023 D Array Restoration 【线段树】

D. Array Restorationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputInitially there was an array aa consisting of nn integers. Po...

2018-08-18 21:41:37 233

原创 codeforces19D Points 【线段树】

Pete and Bob invented a new interesting game. Bob takes a sheet of paper and locates a Cartesian coordinate system on it as follows: point (0, 0) is located in the bottom-left corner, Ox axis is direc...

2018-08-18 19:44:26 226

原创 HDU 4288 Coder 【暴力】OR 【线段树】

 In mathematics and computer science, an algorithm describes a set of procedures or instructions that define a procedure. The term has become increasing popular since the advent of cheap and reliable ...

2018-08-18 10:43:50 172

原创 HDU 2665 Kth number 【主席树】【第K小】

Kth numberTime Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 16136    Accepted Submission(s): 4888 Problem DescriptionGive you a sequence ...

2018-08-15 22:45:12 173

原创 HDU 6395 Sequence 【矩阵快速幂】【分区】

SequenceTime Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1900    Accepted Submission(s): 729 Problem DescriptionLet us define a sequenc...

2018-08-15 21:05:25 129

原创 HDU 6386 Age of Moyu 【bfs】【spfa】

Age of MoyuTime Limit: 5000/2500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 2585    Accepted Submission(s): 784 Problem DescriptionMr.Quin love fishes ...

2018-08-14 23:06:31 186

原创 codeforces 722 C Destroying Array【并查集】【倒插】

C. Destroying Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array consisting of n non-negative integers a...

2018-08-13 10:50:18 157

空空如也

空空如也

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

TA关注的人

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