自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 统计图

题目链接题意:操场上有一排男女的队伍,现在需要找到一个连续的子队伍(就是整个队伍中截取连续的一部分或者全部), 在这个子队伍中需要满足: s[i...x]中的男生比女生多,而s[x+1...j]中的女生比男生多(在这里, i, j表示子队伍的起点和终点,至少有一个x),求满足条件子队伍的最长长度,没有满足的子队伍时,输出0。注:i<=x<j思路:设a[i]表示从0到i的...

2019-12-04 20:55:13 170

原创 Codeforces Round #593 (Div. 2) C. Labs

题目链接题意:n^2个数,n行n列,每行每个数字比另一行数字大的个数总和的最小值最大。例如:在第一次测试中我们可以分开9实验室分组{2,8,5},{9,3,4},{7,6,1}.从第一组到第二组我们可以传送4水单位(8→3,8→4,5→3,5→4).从第一组到第三组,我们可以运输。5水单位(2→1,8→7,8→6,8→1,5→1).从第二组到第一组我们可以传送5水单位(9→...

2019-10-24 23:26:18 133

原创 Codeforces Round #593 (Div. 2) B Alice and the List of Presents

题目链接题意:这些天爱丽丝收到了很多礼物。所以她决定把它们装进盒子寄给她的朋友们。有n种礼物。一种礼物是相同的(即无法区分两种相同的礼物)。不同种类的礼物是不同的(也就是说,两种不同的礼物是可以区分的)。爱丽丝收到的每一种礼物的数量都非常大,所以我们可以认为爱丽丝收到的每一种礼物的数量是无限的。还有m个盒子。他们都是为不同的人,所以他们是两两不同的(考虑到m个朋友的名字写在盒子上)。例如,把第...

2019-10-22 21:20:07 150

原创 Codeforces Round #590 (Div. 3) D - Distinct Characters Queries(单点修改+区间查询)

题目链接题意:给定一个字符串,可以进行两种操作:1posc(1≤pos≤|s|,c是一个小写英文字母): 将第pos位换成c; 2lr(1≤l≤r≤|s|): 查找从l到r中不同字符的个数.只对第二种情况输出结果。思路:用26位二进制表示26个英文字母,使用线段树进行或运算。#include<bits/stdc++.h>using namesp...

2019-10-16 14:21:15 117

原创 Codeforces Round #590 (Div. 3) C. Pipes

题目链接Types of pipesExamples of connected pipesLet's describe the problem using some example:The first example inputAnd its solution is below:题意:从左上角入,从右下角出,每一个图形可以无数次旋转90度。思路:...

2019-10-14 23:24:11 77

原创 Codeforces Round #590 (Div. 3) B2. Social Network (hard version) (set中count())

题目链接题意:信息栏显示问题,信息栏最多显示k个,将依次出现n个信息:新出现的信息如果不在信息栏中,则将最先在信息栏中的信息删除,后将这条信息加入;新出现的信息如果在信息栏中,则不做处理。代码如下:#include<bits/stdc++.h>using namespace std;int a[200010];int main(){ int n,k,b...

2019-10-11 11:15:37 191

原创 强联通分量(tarjan模板)

#include<bits/stdc++.h>using namespace std;const int N=10010;const int M=100010;int timing;vector<int>G[N];//存边int dfn[N];//编号int low[N];//时间戳bool ins[N];//判断是否在栈中stack<int&gt...

2019-09-27 21:57:14 88

原创 Codeforces Round #588 (Div. 2) D. Marcin and Training Camp

题目链接Marcin is a coach in his university. There arennstudents who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other...

2019-09-26 21:33:38 108

原创 Codeforces Round #588 (Div. 2) C. Anadi and Domino (思维+暴力)

题目链接Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For everyaaandbbsuch that1≤a≤b≤61≤a≤b≤6, there is exactly one domino withaadots on one half and...

2019-09-25 09:12:45 172

原创 Codeforces Round #587 (Div. 3) Swords (gcd)

题目链接题意:地下室有相同数目各种不同类型的剑,一群人盗剑,每人只能拿一种类型的剑,且每人拿剑数目相同,至少有一种剑未被盗,已知n种剑,和地下室被盗之后各种剑数目,求最少多少人盗剑,每人盗几把。思路:求被盗各种剑的最大公约数。代码如下:#include<bits/stdc++.h>#define ll long long #define N 200010us...

2019-09-22 08:11:46 106

原创 codeforces1221B Knights (思维)

题目链接You are given a chess board withnnrows andnncolumns. Initially all cells of the board are empty, and you have to put a white or a black knight into each cell of the board.A knight is a che...

2019-09-21 09:15:09 179

原创 zzulioj 2494: 考试排座位

题目描述每到考试时,为了保证每位同学和其周围的同学都不认识,小明想出了如下策略:假设某个考场有 N 个学校的考生,第 i 所学校有 t名考生参加考试。令每校考生排成一列纵队,第 i+1 队的考生排在第 i 队考生之后。从第 1 所学校开始,各校的第 1 位考生顺次入座,然后是各校的第 2 位考生…… 以此类推。如果最后只剩下 1 所学校还没有分配座位,则需要安排他们的考生隔位就坐。但是小...

2019-09-21 08:27:27 179

原创 zzulioj 1708: 01串也疯狂之光棍也有伴

题目描述话说春节那天,小明和晓明在实验室刷题。刷着刷着小明觉得累了,就邀请晓明一起看春晚。晓明觉得小明很无聊,不想理小明,但是小明很会磨嘴皮子,晓明耐不住小明的胡嘴蛮缠,于是和小明一起看起春晚来。小明顿时觉得倍儿爽啊! 可是一看,“wocao”,“最炫小苹果”,小明顿时觉得很伤心。 “连小苹果都有伴了。。。呜呜。。。。” 晓明看到小明哭了,就想安慰他,可是怎么安慰呢!晓明陷入了沉思,...

2019-09-20 00:32:47 138

原创 2019ICPC上海网络赛 J Stone game DP

题目链接样例输入复制231 2 231 2 4样例输出复制21样例解释In example 1, CSL can choose the stone 1 and 2 or stone 1 and 3.In example 2, CSL can choose the stone 3.题意:一堆石子,每个石子有自己的质量,取出部分石子设为A,剩下部分...

2019-09-19 20:26:26 166

原创 2019ICPC上海网络赛 B. Light bulbs 思维+差分思想

题目链接题目大意:有n个灯,m次操作,每次修改[l,r]内的灯,(off - on ,on - off),问最后有几盏灯亮着.题目思路:因为外层有个T,并且n太大,并且卡内存!!!我们只能对m下手,注意到:把每一个端点存起来之后(并且排序),毎两个点之间的区间的 亮与否至于左边有关,不包括右边.当时r没有加一,崩溃了。我们把端点 排好序之后,就直接跑一遍m如果当前...

2019-09-16 09:48:59 109

原创 HDU 6709 Fishing Master(优先队列+贪心)

Heard that eom is a fishing MASTER, you want to acknowledge him as your mentor. As everybody knows, if you want to be a MASTER's apprentice, you should pass the trial. So when you find fishing MAS...

2019-09-16 00:18:40 176

原创 codeforces 1213G (树分治+并查集)

You are given a weighted tree consisting ofnnvertices. Recall that a tree is a connected graph without cycles. Verticesuiuiandviviare connected by an edge with weightwiwi.You are givenmmque...

2019-09-13 09:25:38 296

原创 UVA-12663 水淹桥(二分)

最近下了很大的雨,小P都不能开心的出去玩耍了。所以无聊的小P找事来了。在这些天总共下了很多次雨,每次下雨后,河的水位都会上升一些,然后雨过后水位又会下降到一定位置。在这个河上有许多桥,小P想知道在这些雨过后,有多少桥被淹没不少于k次。如果桥的位置高于当前水位,洪水来后,水位上涨,将桥淹没(水位与桥同等高度也理解为桥被淹没),则计为该桥被淹没一次。第一次洪水来临前,水位为1。如果你...

2019-09-02 23:13:54 95

原创 CodeForces - 659D 思维题

小明从小就喜欢骑自行车,自行车环湖骑行大赛马上开始了,小明当然也参加了。为了能取得更好地成绩,小明想知道在哪些地方需要格外的注意,以防掉湖。现在已知该湖为n边形且形状均由直线和直角组成(可以参照样例解释),小明从起始点沿着环湖路线顺时针骑到终点,求小明可能由于忘记拐弯而导致掉湖的次数。Input第一行一个整数n(4<=n<=1000)下面n+1行每行包含两个数,为每个直角...

2019-09-02 21:45:37 193

原创 1213D2-按分区均衡化(硬体版本)

The only difference between easy and hard versions is the number of elements in the array.You are given an arrayaaconsisting ofnnintegers. In one move you can choose anyaiaiand divide it by22...

2019-09-02 00:03:56 173

原创 Hdu 6153 A Secret(KMP求子串在母串中的前缀长度和)

Today is the birthday of SF,so VS gives two strings S1,S2 to SF as a present,which have a big secret.SF is interested in this secret and ask VS how to get it.There are the things that VS tell:Suff...

2019-08-29 10:44:38 79

原创 poj1226 kmp查找多字符串正逆最长子串或stl中string法

You are given a number of case-sensitive strings of alphabetic characters, find the largest string X, such that either X, or its inverse can be found as a substring of any of the given strings.Inpu...

2019-08-28 10:46:46 91

原创 HDU3336(KMP+DP)

It is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string s, we can write down all the non-empty prefixes of this string. For example:s: "abab...

2019-08-27 21:11:01 94

原创 HDU 2594 KMP求两字符串合并后的前后缀

Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had.Marge: Yeah, what is it?Homer: Take me for example. I want to find out if I have a talent in politics...

2019-08-27 19:57:07 89

原创 POJ 3080 找出m个串中的最长公共子串 二分+爆搜+set

The Genographic Project is a research partnership between IBM and The National Geographic Society that is analyzing DNA from hundreds of thousands of contributors to map how the Earth was populated....

2019-08-27 19:26:32 65

原创 HDU - 3068 最长回文(Manacher(马拉车)算法模板题)

给出一个只由小写英文字符a,b,c...y,z组成的字符串S,求S中最长回文串的长度.回文就是正反读都是一样的字符串,如aba, abba等Input输入有多组case,不超过120组,每组输入为一行小写英文字符a,b,c...y,z组成的字符串S两组case之间由空行隔开(该空行不用处理)字符串长度len <= 110000Output每一行一个整数x,对应一组...

2019-08-27 16:10:57 103

原创 POJ 2752 KMP求前缀后缀的最大匹配长度

The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names to their newly-born babies. They seek the name, and at the same time seek th...

2019-08-27 14:24:49 507

原创 POJ 2406 Power Strings(KMP求循环次数)

Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiation by a non-...

2019-08-27 13:20:05 72

原创 POJ 1961 (KMP求最长连续重复字串)

For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string. That is, for each i (2 ...

2019-08-27 11:24:16 217

原创 HDU3746 Cyclic Nacklace (KMP求循环节)

CC always becomes very depressed at the end of this month, he has checked his credit card yesterday, without any surprise, there are only 99.9 yuan left. he is too distressed and thinking about how to...

2019-08-27 10:48:01 81

原创 HDU 2087 剪花布条(KMP 模板求不叠加模式串个数)

一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢?Input输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCII字符有多少个,布条的花纹也有多少种花样。花纹条和小饰条不会超过1000个字符长。如果遇见#字符,则不再进行工作。Output...

2019-08-27 09:11:20 77

原创 HDU 1686 Oulipo(KMP算法求模式串在目标串中的个数)

The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a member of the Oulipo group. A quote from the book:Tout avait Pair normal, mais tout s’...

2019-08-26 21:51:45 142

原创 HDU 1711 Number Sequence(KMP算法求模式串开头位置)

Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a number K which make a[K] = b[1], a[K ...

2019-08-26 21:06:24 76

原创 codeforces1084c找对方法,组合,(或者dp)

这里有一个由小写字母构成的字符串S . 小I是一个好(tao)奇(qi)的男孩,因此他想要找严格递增数字序列P(P_1到P_k)的数量,每个序列必须满足以下要求:1. 1<=i<=k 时,S[P_i] = 'a'.2. 1<=i<k 时 , 保证存在 整数 j ,j满足P_i<j<P_(i+1),而且s[j]='b'.小I很烦恼(翻译题面的我也很烦恼...

2019-08-26 16:11:38 150

原创 HihoCoder - 1514  三数组最接近的三个数(二分)

众所周知,小明家里有kuang,小明想买三台电视机一起看电视。 显然,三台电视机之间高度差越小越好 给你三个数组,请从每个数组选一个数,假设选出的是x, y, z,请让|x-y|+|y-z|+|x-z|最小Input第一行包含3个整数,N, M和L。 第二行包含N个整数,A1, A2, ... AN。(1 <= Ai<= 1e8)第三行包含M个整数,B1...

2019-08-25 21:38:13 98

原创 CodeForces - 1028B (数论)

s(x)表示x每位数的数字和。现在给你两个整数n,m,请找出两个符合下列条件的整数a,b:1. s(a) >= n2. s(b) >= n3. s(a+b) <= mInput输入两个整数n,m。(1 <= n,m <= 1129)Output输出两个正整数a,b。本题特判,如有多种答案,输出任意一种即可。(a,b都没有前导零,a,b的位数都不...

2019-08-25 20:36:41 245

原创 CodeForces - 878D 递归(搜索)

开始有k个生物,有n个属性支持3种操作:1.将两个生物合并成一个新的生物,所有属性值为原来的较大值2.将两个生物合并成一个新的生物,所有属性值为原来的较小值3.询问i生物的第j个属性值n<=1e5 k<=12 q<=1e5Input三个数 n k q分别表示属性数,生物数以及操作数之后k行每行n个正整数,表示生物属性(属于[1,1e9])之后q行,每行3个...

2019-08-25 20:17:26 242

原创 HDU 1827 Summer Holiday

To see a World in a Grain of SandAnd a Heaven in a Wild Flower,Hold Infinity in the palm of your handAnd Eternity in an hour.—— William Blake听说lcy帮大家预定了新马泰7日游,Wiskey真是高兴的夜不...

2019-08-24 20:18:09 80

原创 POJ 2168 Popular Cows

在zyh的高中,学生会每一年都会评选受欢迎学生,所谓受欢迎的学生,就是被所有学生喜欢的学生。 每个学生都喜欢自己,碰巧的是,如果学生A 喜欢学生B ,学生B喜欢学生C, 那么学生A也喜欢学生C。 但是学生A喜欢学生B 并不意味着学生B喜欢学生A。 zyh参与了评选工作,苦逼的他被安排去购买奖品,于是他拿到了一张表,这张表有m条记录,每条记录由两个数字a,b组成,表示a,喜欢b ,但是由于学生太多了...

2019-08-24 09:32:45 97

原创 HDU 1269 迷宫城堡(强联通分量)

为了训练小希的方向感,Gardon建立了一座大城堡,里面有N个房间(N<=10000)和M条通道(M<=100000),每个通道都是单向的,就是说若称某通道连通了A房间和B房间,只说明可以通过这个通道由A房间到达B房间,但并不说明通过它可以由B房间到达A房间。Gardon需要请你写个程序确认一下是否任意两个房间都是相互连通的,即:对于任意的i和j,至少存在一条路径可以从房间i到房间j,...

2019-08-22 21:39:46 64

空空如也

空空如也

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

TA关注的人

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