自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 codeforces140D贪心

洛谷的翻译有遗漏,做题之前有10分钟读题时间,所以是从16:10开始做题的。给每题的做题时间排序,然后累加,直到超出时间限制,然后判断超出24:00的题目罚时。#include<iostream>#include<algorithm>#include<string>#include<cstring>#include<cstdio>#include<cmath>using namespace std;typedef l.

2020-10-21 21:24:47 104

原创 codeforces 33C最大子序列

如果前缀后缀交叉,交叉部分值不变,那么求出原序列的最大子序列,最大子序列前后部分一定是负的,翻转前后部分得到最大的序列,ans=最大子序列-(总和-最大子序列)。#include<iostream>#include<algorithm>#include<string>#include<cstring>#include<cmath>#include<cstdio>using namespace std;typedef l.

2020-10-21 21:20:08 144

原创 codeforces 1303D 贪心

二进制处理N,拆分成若干个2的i次方,然后记录下每个2的次方有多少个盒子,按位查询N拥有的2的次方盒子有没有,没有的话就往上找大的盒子拆,如果盒子没用上就合并成大的盒子。#include<iostream>#include<algorithm>#include<string>#include<cstring>#include<cmath>#include<cstdio>using namespace std;typed.

2020-10-21 21:10:26 101

原创 CF1175D 思维题 后缀和数组

数组分成K段,第K段的数会被累加k次,所以用后缀和数组找到累加值最大的k-1段,再加上整个数组的和就是答案。#include<iostream>#include<algorithm>#include<string>#include<cstring>#include<cmath>#include<cstdio>using namespace std;typedef long long ll;int a[300010];.

2020-10-19 18:39:56 84

原创 codeforces Round 96 Div2 D

D. String Deletiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a string s consisting of n characters. Each character is either 0 or 1.You can perform operations on the string. Each ope

2020-10-12 14:26:59 135

原创 codeforces#667 div3

A#include<algorithm>#include<string>#include<cstring>#include<cmath>#include<cstdio>using namespace std;int main(){ int n; int a,b; cin>>n; while(n--) { cin>>a>>b; int sum=abs(a-b); if(s

2020-09-07 20:55:05 161

原创 cf1138B枚举

Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then ci=1, otherwise ci=0), and whether they can perform as an acrobat (if yes, then ai=1, othe

2020-09-01 16:37:20 112

原创 codeforces 1202D思维构造

The subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.You are given an integer n.You have to find a sequence s consisting of digits {1,3,7} such that it has

2020-08-21 16:12:32 125

原创 codeforces371D 并查集

There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is a i liters.Initially, all the vessel

2020-08-18 22:35:03 141

原创 codeforces 811C dp

Vladik often travels by trains. He remembered some of his trips especially well and I would like to tell you about one of these trips:Vladik is at initial train station, and now n people (including Vladik) want to get on the train. They are already lined

2020-08-18 22:14:38 189

原创 codeforces87B模拟

Programmer Vasya is studying a new programming language &K*. The &K* language resembles the languages of the C family in its syntax. However, it is more powerful, which is why the rules of the actual C-like languages are unapplicable to it. To full

2020-08-17 20:37:48 161

原创 cf1250B贪心

Employees of JebTrains are on their way to celebrate the 256-th day of the year! There are n employees and k teams in JebTrains. Each employee is a member of some (exactly one) team. All teams are numbered from 1 to k. You are given an array of numbers t1,

2020-07-26 15:56:43 145

原创 cf1038D水题

There are n slimes in a row. Each slime has an integer value (possibly negative or zero) associated with it.Any slime can eat its adjacent slime (the closest slime to its left or to its right, assuming that this slime exists).When a slime with a value x

2020-07-26 15:45:09 241

原创 cf 208C最短路

The Berland road network consists of n cities and of m bidirectional roads. The cities are numbered from 1 to n, where the main capital city has number n, and the culture capital — number 1. The road network is set up so that it is possible to reach any ci

2020-07-23 22:21:53 225

原创 树状数组 区间更新区间查询

令原数组为A,差分数组为D建立两个树状数组,一个存储差分数组,一个存储(i−1)⋅D i数组。#include<iostream>using namespace std;int n,m; int a[100010]={0},d1[100010],d2[100010];int lowbit(int x){ return x&(-x);}void query(int cnt,int x){ int t=cnt; while(cnt<=n) { d1[c

2020-05-17 12:43:52 150

原创 前缀和差分处理区间更新单点查询模板

给定一个数组A,对其进行q次操作,每次给定l、r,对A【l-r】区间内所有数增加x,最后输出修改后每个数的值。前缀和+差分处理,时间复杂度O(n+q)。#include<iostream>#include<string>#include<cstring>#include<algorithm>using namespace std;int a[100010];//原数组 int d[100010];//差分数组 int sum[100010];

2020-05-15 11:44:24 245

原创 树状数组 区间更新单点查询

在单点更新的基础上运用差分的思想来构建树状数组。对于一个数组A,建立数组D来记录数组A中连续数值的差值,即D【i】=A【i】-A【i-1】。而A【i】=D【1】+D【2】+…+D【i】。如果对数组A进行区间更新,将区间【L-R】每个数加上X,对于数组D来说,【L-R】的值是不发生变化的,D【l-1】会增加X,D【R+1】会减小X,所以区间更新A时只需要更改D数组中D【l-1】,D【R+1】两项的值即可。然后对D建立树状数组。#include<iostream>using namespa

2020-05-14 19:17:03 263

原创 树状数组 单点更新区间查询

黑色为原数组,红色即为树状数组,通过lowbit求得“子节点”或者“父节点”。求区间和操作类似前缀和,区间【L,R】的和为树状数组【R】–树状数组【L-1】。修改和查询的时间复杂度均为O(logN)。代码简单系数小。功能有限处理不了复杂区间问题。#include<iostream>using namespace std;int n,m;int a[1000010];//树状数组 int lowbit(int x){ return x&(-x);}void up.

2020-05-14 17:55:36 135

原创 埃氏筛应用-牛客-炫酷数字

题目链接题目描述:小希希望你构造一个最小的正整数,使得其有n个因子。输入描述:第一行一个整数T表示数据组数每组数据第一行输入一个正整数n,表示其因子数。n≤1,000,000T≤1,000,000输出描述:输出一行一个整数,表示你构造出的这个数。注意:你需要保证你构造的数≤1,000,000≤1,000,000,如果在这个范围里面无法构造出一个正整数满足条件,请输出-1。#in...

2020-04-29 14:08:27 109

原创 判断质数-从试除到欧拉筛模板

1.最朴素的判断素数-试除法using namespace std;int n;bool is_prime(int n){ if(n<2) return false; for(int i=2;i<n;i++) if(n%i==0) return false; return true;}int main (){ while(cin>&g...

2020-04-29 13:38:55 127

原创 11.20B

题目链接HOHO,终于从Speakless手上赢走了所有的糖果,是Gardon吃糖果时有个特殊的癖好,就是不喜欢将一样的糖果放在一起吃,喜欢先吃一种,下一次吃另一种,这样;可是Gardon不知道是否存在一种吃糖果的顺序使得他能把所有糖果都吃完?请你写个程序帮忙计算一下。Input第一行有一个整数T,接下来T组数据,每组数据占2行,第一行是一个整数N(0<N<=1000000),第...

2019-12-15 20:37:40 75

原创 小猪存钱罐 完全背包

题目链接Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is s...

2019-12-15 20:03:18 179

原创 树的扩充

檀黎斗社长在开发神极限卡带的过程中出现了问题,他发现了图论意义上一棵有N个节点的树,但他觉得还不够好,打算动用神之才能增加若干条边,使得N个节点中任意两点都有直接相连的边,并满足新图的唯一极小连通子图仍然一开始的树。社长知道这样有很多种增加策略,但为了公司经营,需要消耗尽量少,即新增的边权值和的最小值。Input第一行包含整数t,表示共有t组测试数据。对于每组测试数据,第一行包含整数N。...

2019-12-09 09:20:42 207

原创 完全背包

题目链接:完全背包模板题有 N 种物品和一个容量是 V 的背包,每种物品都有无限件可用。第 i 种物品的体积是 vi,价值是 wi。求解将哪些物品装入背包,可使这些物品的总体积不超过背包容量,且总价值最大。输出最大价值。输入格式第一行两个整数,N,V,用空格隔开,分别表示物品种数和背包容积。接下来有 N 行,每行两个整数 vi,wi,用空格隔开,分别表示第 i 种物品的体积和价值。...

2019-11-29 08:26:34 62

原创 01背包

题目连接:01背包模板题有 N 件物品和一个容量是 V 的背包。每件物品只能使用一次。第 i 件物品的体积是 vi,价值是 wi。求解将哪些物品装入背包,可使这些物品的总体积不超过背包容量,且总价值最大。输出最大价值。输入格式第一行两个整数,N,V,用空格隔开,分别表示物品数量和背包容积。接下来有 N 行,每行两个整数 vi,wi,用空格隔开,分别表示第 i 件物品的体积和价值。输...

2019-11-28 20:02:06 61

原创 最小生成树

最小生成树是一副连通加权无向图中一棵权值最小的生成树。解决最小生成树一般有两种算法,克鲁斯卡尔算法(Kruskal Algorithm)和普利姆算法(Prim Algorithm)。克鲁斯卡尔算法的核心就在带权连通图中,不断地在边集合中找到最小的边,如果该边满足得到最小生成树的条件,就将其构造,直到最后得到一颗最小生成树。用并查集来判断当前路径是否出现过。普利姆算法的核心步骤是在带权连通图中...

2019-11-16 20:06:35 911

原创 并查集

并查集是树形的数据结构,用于处理一些不交集的合并及查询问题。并查集模板题:https://vjudge.net/problem/19354/origin通过合并子集将所有相关联的元素归并到一棵树上。通过递归查找元素的根节点。#include<cstdio>#include<algorithm>#include<string>#include<...

2019-11-15 19:58:49 65

原创 9.22

ac自动机题目链接:https://vjudge.net/problem/16404/origin当太阳的光辉逐渐被月亮遮蔽,世界失去了光明,大地迎来最黑暗的时刻。。。。在这样的时刻,人们却异常兴奋——我们能在有生之年看到500年一遇的世界奇观,那是多么幸福的事儿啊~~但网路上总有那么些网站,开始借着民众的好奇心,打着介绍日食的旗号,大肆传播病毒。小t不幸成为受害者之一。小t如此生气,他决定...

2019-09-28 20:10:30 67

原创 9.22

manacher题目链接:https://vjudge.net/problem/22336/originNow, you are given a string S. We want to know how many distinct substring of S which is palindrome.InputThe first line of the input contains a ...

2019-09-28 20:08:22 91

原创 9.20

ac自动机模板题题目链接:https://vjudge.net/problem/16403/originIn the modern time, Search engine came into the life of everybody like Google, Baidu, etc.Wiskey also wants to bring this feature to his image re...

2019-09-28 20:02:09 85

原创 9.18A

01字典树模板题题目链接:https://vjudge.net/problem/67301/originZeus 和 Prometheus 做了一个游戏,Prometheus 给 Zeus 一个集合,集合中包含了N个正整数,随后 Prometheus 将向 Zeus 发起M次询问,每次询问中包含一个正整数 S ,之后 Zeus 需要在集合当中找出一个正整数 K ,使得 K 与 S 的异或结果最...

2019-09-28 19:50:14 112

原创 9.16

字典树模板题题目链接:https://vjudge.net/problem/16379/originIgnatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀).Input输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单...

2019-09-28 19:40:26 156

原创 9.7A

题目链接https://vjudge.net/problem/16282/originGive you a string with length N, you can generate N strings by left shifts. For example let consider the string “SKYLONG”, we can generate seven strings:St...

2019-09-12 18:55:48 110

原创 9.10B

题目链接https://vjudge.net/problem/26048/originLittle Petya very much likes gifts. Recently he has received a new laptop as a New Year gift from his mother. He immediately decided to give it to somebody ...

2019-09-12 18:46:25 96

原创 9.10A

题目链接https://vjudge.net/problem/2638259/originString matching is a common type of problem in computer science. One string matching problem is as following:Given a string [Math Processing Error]s[0…le...

2019-09-12 18:43:59 149

原创 9.9B

题目链接https://vjudge.net/problem/27861/originIlya plays a card game by the following rules.A player has several cards. Each card contains two non-negative integers inscribed, one at the top of the car...

2019-09-12 18:28:19 80

原创 9.9 A

题目链接https://vjudge.net/problem/10934/originFor 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 ...

2019-09-12 18:22:30 129

原创 十六周任务 简易最短路

寒假的时候,ACBOY要去拜访很多朋友,恰巧他所有朋友的家都处在坐标平面的X轴上。ACBOY可以任意选择一个朋友的家开始访问,但是每次访问后他都必须回到出发点,然后才能去访问下一个朋友。比如有4个朋友,对应的X轴坐标分别为1, 2, 3, 4。当ACBOY选择坐标为2的点做为出发点时,则他最终需要的时间为 |1-2|+|2-2|+|3-2|+|4-2| = 4。现在给出N个朋友的坐标,那么AC...

2018-12-12 20:32:52 118

原创 第七次测试 折线分割

我们看到过很多直线分割平面的题目,今天的这个题目稍微有些变化,我们要求的是n条折线分割平面的最大数目。比如,一条折线可以将平面分成两部分,两条折线最多可以将平面分成7部分,具体如下所示。Input输入数据的第一行是一个整数C,表示测试实例的个数,然后是C 行数据,每行包含一个整数n(0&lt;n&lt;=10000),表示折线的数量。Output对于每个测试实例,请输出平面的最大分割数,...

2018-12-12 15:35:14 104

原创 第七次测试 错排

HDU 2006’10 ACM contest的颁奖晚会隆重开始了!为了活跃气氛,组织者举行了一个别开生面、奖品丰厚的抽奖活动,这个活动的具体要求是这样的:首先,所有参加晚会的人员都将一张写有自己名字的字条放入抽奖箱中;然后,待所有字条加入完毕,每人从箱中取一个字条;最后,如果取得的字条上写的就是自己的名字,那么“恭喜你,中奖了!”大家可以想象一下当时的气氛之热烈,毕竟中奖者的奖品是大家...

2018-12-11 22:53:43 145

空空如也

空空如也

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

TA关注的人

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