自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

深海沧澜的博客

不存在十全十美的文章,如同不存在彻头彻尾的绝望。

  • 博客(48)
  • 资源 (1)
  • 收藏
  • 关注

原创 POJ - 3764 The xor-longest Path 字典树+异或

题意:给定一棵N个节点的树,树上的每条边都有一个权值,从树中选择两个点x和y,把从x到y路径上的所有边权xor异或起来,得到的最大结果是多少。思路:相同部分异或为0,所以从x到y路径上的边权的xor结果为D[x] xor D [y] ,将x到根与y到根的重叠部分恰好抵消掉。可以先用DFS得到所有的D[x],然后题目变成了D[1]-D[i]  选两个数字异或的结果最大...

2018-07-31 15:51:09 265

原创 CH 1602 The XOR Largest Pair 字典树+异或

描述在给定的N个整数A1,A2……AN中选出两个进行xor运算,得到的结果最大是多少?输入格式第一行一个整数N,第二行N个整数A1~AN。输出格式一个整数表示答案。样例输入31 2 3样例输出3数据范围与约定对于100%的数据: N<=10^5, 0<=Ai<2^31。思路:寻找2个数异或的最大值,我们把每个整数看做长度为32的二进制的01串(数...

2018-07-31 15:44:31 1125

原创 CH 1601 前缀统计 字典树模板题目

描述给定N个字符串S1,S2...SN,接下来进行M次询问,每次询问给定一个字符串T,求S1~SN中有多少个字符串是T的前缀。输入字符串的总长度不超过10^6,仅包含小写字母。输入格式第一行两个整数N,M。接下来N行每行一个字符串Si。接下来M行每行一个字符串表示询问。输出格式对于每个询问,输出一个整数表示答案样例输入3 2abbcabcabcefg样例输出20...

2018-07-31 15:27:02 448

原创 Kattis - flowfree Flow Free 多个两点的DFS

grid of cellsFlow Free is a puzzle that is played on a 2D grid of cells, with some cells marked as endpoints of certain colors and the rest of cells being blank.To solve the puzzle, you have to ...

2018-07-30 11:08:27 884

原创 Kattis - multiplicationgame Multiplication Game 博弈因子相乘是否等于N

Alice and Bob are in their class doing drills on multiplication and division. They quickly get bored and instead decide to play a game they invented.The game starts with a target integer N≥2, and an...

2018-07-30 11:03:56 339

原创 Kattis - palindromicpassword Palindromic Password 求最接近的回文数

The IT department at your school decided to change their password policy. Each password will have to consist of N 6-digit numbers separated by dashes, where N will be determined by the phase of the mo...

2018-07-30 11:00:12 320

原创 Kattis - froshweek2 Frosh Week 类二分图匹配

Professor Zac is trying to finish a collection of tasks during the first week at the start of the term. He knows precisely how long each task will take, down to the millisecond. Unfortunately, it is a...

2018-07-30 10:55:26 314

原创 POJ - 3974 Palindrome 最长的回文子串 3种不同的方法 字符串hash/Manacher算法

Andy the smart computer science student was attending an algorithms class when the professor asked the students a simple question, "Can you propose an efficient algorithm to find the length of the lar...

2018-07-30 10:50:42 1165

原创 CH 1401 兔子与兔子 字符串hash

描述很久很久以前,森林里住着一群兔子。有一天,兔子们想要研究自己的 DNA 序列。我们首先选取一个好长好长的 DNA 序列(小兔子是外星生物,DNA 序列可能包含 26 个小写英文字母),然后我们每次选择两个区间,询问如果用两个区间里的 DNA 序列分别生产出来两只兔子,这两个兔子是否一模一样。注意两个兔子一模一样只可能是他们的 DNA 序列一模一样。输入格式第一行一个 DNA 字符串 S...

2018-07-30 10:44:49 369 2

原创 POJ - 3349 Snowflake Snow Snowflakes hash 判断六角是否相同

You may have heard that no two snowflakes are alike. Your task is to write a program to determine whether this is really true. Your program will read information about a collection of snowflakes, and ...

2018-07-30 10:32:20 224

原创 POJ 2054 /HDU 1055 Color a Tree(贪心+并查集)

Bob is very interested in the data structure of a tree. A tree is a directed graph in which a special node is singled out, called the "root" of the tree, and there is a unique path from the root to ea...

2018-07-27 15:46:36 305 1

原创 CH 0503 奇数码问题 树状数组

描述你一定玩过八数码游戏,它实际上是在一个3*3的网格中进行的,1个空格和1~8这8个数字恰好不重不漏地分布在这3*3的网格中。例如:5 2 81 3 _4 6 7在游戏过程中,可以把空格与其上、下、左、右四个方向之一的数字交换(如果存在)。例如在上例中,空格可与左、上、下面的数字交换,分别变成:5 2 8       5 2 _      5 2 81 _ 3       1...

2018-07-27 10:14:16 317

原创 HDU 6301 Distinct Values 思维模拟+优先队列

Problem DescriptionChiaki has an array of n positive integers. You are told some facts about the array: for every two elements ai and aj in the subarray al..r (l≤i<j≤r), ai≠aj holds.Chiaki would...

2018-07-26 19:30:10 211

原创 HDU 6299 Balanced Sequence 括号匹配 贪心

Problem DescriptionChiaki has n strings s1,s2,…,sn consisting of '(' and ')'. A string of this type is said to be balanced:+ if it is the empty string+ if A and B are balanced, AB is balanced,+ i...

2018-07-26 19:20:13 266

原创 BZOJ 3211 花神游历各国 势能线段树 开平方 暴力更新

 Description InputOutput每次x=1时,每行一个整数,表示这次旅行的开心度 Sample Input41 100 5 551 1 22 1 21 1 22 2 31 1 4Sample Output1011111HINT对于100%的数据, n ≤ 100000,m≤200000 ,data[i]非负且...

2018-07-26 14:12:22 255

原创 HDU 6318 Swaps and Inversions 逆序數 归并排序或树状数组+离散化

Problem DescriptionLong long ago, there was an integer sequence a.Tonyfang think this sequence is messy, so he will count the number of inversions in this sequence. Because he is angry, you will hav...

2018-07-26 13:30:46 190

原创 HDU-6315 Naive Operations 势能线段树 ai/bi

Problem DescriptionIn a galaxy far, far away, there are two integer sequence a and b of length n.b is a static permutation of 1 to n. Initially a is filled with zeroes.There are two kind of operat...

2018-07-26 12:02:31 309

原创 Kattis - politics The Uncertainty of Politics 区间首尾相间 数学期望

You have an upcoming trip to Washington D.C. and you are fascinated with the intricacies of Congressional committee hearings. You wish to attend as many hearings as possible during your trip, and your...

2018-07-25 11:02:02 294

原创 Kattis - orderlyclass Orderly Class 字符串中心对称问题

Ms. Thomas is managing her class of nn students.She placed all her students in a line, and gave the ii-th student from the left a card with the letter aiai written on it.She would now like to rear...

2018-07-25 10:47:23 339

原创 Kattis - hopscotch Hopscotc 组合数(逆元)

You’re playing hopscotch! You start at the origin and your goal is to hop to the lattice point (N,N)(N,N). A hop consists of going from lattice point (x1,y1)(x1,y1) to (x2,y2)(x2,y2), where x1<x2x1...

2018-07-25 10:44:53 344

原创 Kattis faultyrobot Faulty Robot DFS+处理图中节点头尾关系

As part of a CS course, Alice just finished programming her robot to explore a graph having nn nodes, labeled 1,2,…,n1,2,…,n, and mm directed edges. Initially the robot starts at node 11.While nodes...

2018-07-25 09:41:01 453

原创 BZOJ 3032 CH0502 七夕祭 中位数 + 前缀和

个人觉得写得非常好,所以直接借鉴(toulan)参考#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>#include <map>#include <set>#include <queue>#i

2018-07-24 18:28:01 359

原创 POJ 3784 Running Median 动态求中位数 优先队列 小根堆+大根堆

题意:输入M个数,当已输入的个数为奇数个时输出此时的中位数。一共有M/2+1个中位数要输出,每一行10个。思路:当数字是奇数的时候才输出中位数,所以是数组的一半我们可以用小跟堆+大根堆来进行维护,设当前序列长度为M,我们始终保持1--M/2的数字存储在大根堆中(从大到小),M/2+1--M的数字存储在小根堆中,当某一个堆中的元素过多的时候,取出该堆的堆顶入另外一个堆。所以,中位数为小根堆的...

2018-07-24 18:10:31 628

原创 POJ - 2018 Best Cow Fences (二分 连续数的平均和+前缀和)

Farmer John’s farm consists of a long row of N (1 <= N <= 100,000)fields. Each field contains a certain number of cows, 1 <= ncows <= 2000.FJ wants to build a fence around a contiguous g...

2018-07-24 10:54:43 1110 1

原创 递归与枚举 CH0301 CH0302 CH0303

1.递归实现指数型枚举从1——n这n(n<20)个数中随机选取任意多个。输出所有可能的方案,等价于每个整数可以选或者不选,所有的方案为2^n种,DFS思想,选与不选,选了之后要回溯#include <cstdio>#include <iostream>#include <cstring>#include <algorithm&gt...

2018-07-24 10:23:47 356

原创 BZOJ 1218 激光炸弹 矩形权值问题 (前缀暴力&线段树)

题意:给定平面上的n个点,求一个r*r的正方形最多覆盖多少个点使得权值最大(正方形边刚好覆盖的点不算入其内)思路:1.暴力:前缀和得到每行和每列的权值,再利用正方形枚举前缀和枚举,注意计算正方形覆盖时需用到容斥原理#include <cstdio>#include <iostream>#include <cstring>#include &l...

2018-07-23 11:15:09 303

原创 区块链之搭建区块链平台及智能合约的编写

区块链技术:智能合约入门https://github.com/FISCO-BCOS/FISCO-BCOS/blob/master/doc/manual/README.mdubuntu 16.04 安装git的方法https://blog.csdn.net/qq282330332/article/details/51855252区块链环境要求的硬件配置https://github...

2018-07-22 16:36:23 2978 1

原创 7.17-7.19生活记录

       7.17互联网+初赛结束,但是没有想到7.18又来一次,心态爆炸,招就处朝令夕改,互联网+说实话对于我们专业的技术性相对较小而且只是在湖南省长沙市打的比赛,感觉学到的较少,不如深创杯可以去深创看一下,开阔下视野QAQ,实际上可以出去玩哈哈哈,ACM玩的太少了,都是当天去当天回,学校不肯出钱去打比赛,无法提升队伍的积极性,感觉发展不利。     树状数组总结初步完毕,准备开始线段树...

2018-07-21 09:35:37 204

原创 POJ 2482 线段树 离散化 扫描线 矩阵最大权值

题意:给出n个星星的坐标,每个星星有一个亮度,给出一个矩形的长和宽,问矩形能包括的星星的最大亮度和(不包括边框)。思路: 平面上有若干个区域,每个区域都带有一个权值,求在那个实际上重叠的区域权值和最大。使用扫描线算法,取出每个区域的左右边界,保存2个四元组,(x,y,y+h,c) (x+w,y,y+h,-c),按照第一维的大小排序。同时关于y建立一颗线段树,维护区间最大值max1,可以认为线段...

2018-07-21 09:30:41 335

原创 HDU 1542 POJ 1151 Atlantis 线段树+离散化+扫描线 重叠矩阵面积和

There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. Some of these texts even include maps of parts of the island. But unfortunately, these maps describe diff...

2018-07-20 17:13:16 295

原创 POJ 2299 Ultra-QuickSort 求原始序列的逆序对数 树状数组+离散化

In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the sequence is sorted i...

2018-07-19 15:52:17 184

原创 树状数组总结

经过了5天的练习,再看了一遍树状数组,虽然第一遍基本没有怎么看,再看的时候可能是因为年龄和思维比大一更强了一点,所以再看的时候比第一次的一头雾水好了很多很多。接下来进行总结。树状数组或者二叉索引树也称作Binary Indexed Tree,又叫做Fenwick树;它的查询和修改的时间复杂度都是log(n),空间复杂度则为O(n),这是因为树状数组通过将线性结构转化成树状结构,从而进行跳跃式扫...

2018-07-19 15:37:17 163

原创 POJ1195:Mobile phones 二维树状数组 矩阵上点的区间和(查询更新均为二维)

DescriptionSuppose that the fourth generation mobile phone base stations in the Tampere area operate as follows. The area is divided into squares. The squares form an S * S matrix with the rows and ...

2018-07-19 12:24:10 251

原创 7.14--7.16生活记录

   15日得知了双创和深创同时进入了半决赛,有点小开心,因为互联网+个人觉得省不省赛无所谓了,对我们的专业其实帮助不大的,不如深创杯还可以去深圳玩一圈看看其他地方,一直呆在湖南湘潭最多去个长沙感觉都要发霉了,间接被学校囚禁了。学校只支持教育部主办的比赛,对行业和协会的支持很小,所以我校ACM的发展可能逐渐走向衰弱 ,随着时代的变化,当下的生计才是最重要的,ACM对很多普通一本学校的学生无疑是一个...

2018-07-17 17:41:03 308

原创 HDU - 1394 Minimum Inversion Number 求逆序数对 树状数组 (水题的理解)

The inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i < j and ai > aj. For a given sequence of numbers a1, a2, ..., an, if we move the ...

2018-07-17 17:17:49 210

原创 HDU - 4267 A Simple Problem with Integers 三维树状数组

Let A1, A2, ... , AN be N elements. You need to deal with two kinds of operations. One type of operation is to add a given number to a few numbers in a given interval. The other is to query the value ...

2018-07-17 16:48:46 160

原创 POJ 2481 Cows 树状数组 单点更新 (每个集合是几个集合的真子集)

DescriptionFarmer John's cows have discovered that the clover growing along the ridge of the hill (which we can think of as a one-dimensional number line) in his field is particularly good. Farmer ...

2018-07-17 16:44:06 212

原创 poj 2352 Stars 树状数组 单点更新

 Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher a...

2018-07-16 23:48:38 185

原创 HDU 1556 Color the ball 树状数组 区间更新

N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗?Input每个测试实例第一行为一个整数N,(N <= 100000).接下来的N行,每行包括2个整数a ...

2018-07-16 23:25:01 151

原创 2018.7.13 生活记录

今天开始了互联网+的培训,说实话好无聊好无聊,又打了半天的游戏,互联网+最近心力憔悴,但是不得不佩服招就大哥,留了一手,把资料留了下来,可怕可怕实在可怕。开始着手准备ACM了,现在的初定计划是搞3个月的算法,然后打完PAT和网络赛看情况退役,准备去搞项目开发。做一件事就要付出百分之百的精力,ACM今年我不想再留遗憾了,希望天时地利人和吧。...

2018-07-14 09:06:10 205

虚拟机VM Virtual Box 下ubuntu 编译内核 与 简单的Hello Word模块的添加删除教程

虚拟机VM Virtual Box 下ubuntu 编译内核 与 简单的Hello Word模块的添加删除教程

2018-03-28

空空如也

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

TA关注的人

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