自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 暑期训练第四周

A有n头海象位于一个队列中,它们的年龄为a[i],第1头海象在队尾,第n头海象在队首。如果第i只海象队伍的前面有一只海象的年龄比它小,那么这只海象就会不高兴,并且两只海象的距离越远,第i只海象的不高兴程度就会越高。求出每只海象的不高兴度(如果第i只海象没有不高兴输出-1,否则输出第i只海象和让它不高兴的那只海象之间隔了多少只海象)。B有n头海象位于一个队列中,它们的年龄为a[i],第1头海象在队尾,第n头海象在队首。如果第i只海象队伍的前面有一只海象的年龄比它小,那么这只海象就会不高兴,并且两只海象的

2020-07-31 23:24:12 253

原创 树状数组总结

树状数组告一段落了,我做了不少相关的练习题,这篇博客主要来讲一下这段时间做题时的一些感想。首先我认为树状数组也可以说是一个工具,因为它的写法是唯一的,应用场景也是固定的。它不像线段树这样的数据结构,对于不同的题目/不同的要求,线段树中维护的辅助信息也是不同的。我做了不少树状数组的题目,树状数组的写法是都是一样的(我只见过一种扩展用法),用法也是固定的,都是单点修改和区间和查询这两个操作。因此我认为:树状数组和前缀和、离散化、排序这样的知识点都是用法固定的工具,当有特定的需要时就直接拿来用即可。例如:当需

2020-07-31 18:08:30 254

原创 P6278 [USACO20OPEN]Haircut G

题目描述Farmer John 由于对整理他难以整平的头发感到疲惫,于是决定去理发。他有一排 N 缕头发,第 i缕头发初始时长度为 Ai​微米(0≤Ai​≤N)。理想情况下,他想要他的头发在长度上单调递增,所以他定义他的头发的“不良度”为逆序对的数量:满足 i < j 及 Ai​>Aj​ 的二元对 (i,j)。对于每一个 j=0,1,…,N−1,Farmer John 想要知道他所有长度大于 j 的头发的长度均减少到 j 时他的头发的不良度。(有趣的事实:人类平均确实有大约 105根头发

2020-07-30 23:54:25 579

原创 P5094 [USACO04OPEN]MooFest

题目描述每一年,约翰的N只奶牛参加奶牛狂欢节。这是一个全世界奶牛都参加的大联欢。狂欢节包括很多有趣的活动,比如干草堆叠大赛、跳牛栏大赛,奶牛之间有时还相互扎屁股取乐。当然,她们会排成一列嚎叫,来欢庆她们的节日。奶牛们的叫声实在刺耳,以致于每只奶牛的听力都受到不同程度的损伤。现在告诉你奶牛i的听力为vi ,这表示如果奶牛j想说点什么让她听到,必须用高于vi​×dis(i,j) 的音量。因此,如果奶牛i和j想相互交谈,她们的音量必须不小于max(vi​,vj​)×dis(i,j)。其中 dis(i,j) 表

2020-07-30 22:34:34 505

原创 P2880 [USACO07JAN]Balanced Lineup G(树状数组维护序列最值)

题目描述For the daily milking, Farmer John’s N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the cows. To keep things simple, he will take a contiguous range of cows fr

2020-07-30 21:49:44 583

原创 P4868 Preprefix sum

题目描述输入格式第一行给出两个整数N,M。分别表示序列长度和操作个数接下来一行有N个数,即给定的序列a1,a2,…an接下来M行,每行对应一个操作,格式见题目描述输出格式对于每个询问操作,输出一行,表示所询问的SSi的值。样例输入5 31 2 3 4 5Query 5Modify 3 2Query 5输出3532说明/提示1<=N,M<=100000,且在任意时刻0<=Ai<=100000题目分析这也是一道比较典型的用树状

2020-07-30 21:09:51 312

原创 你能回答这些问题吗

题目描述给定长度为N的数列A,以及M条指令,每条指令可能是以下两种之一:1、“1 x y”,查询区间 [x,y] 中的最大连续子段和,即 maxx≤l≤r≤y{∑ri=lA[i]}。2、“2 x y”,把 A[x] 改成 y。对于每个查询指令,输出一个整数表示答案。输入格式第一行两个整数N,M。第二行N个整数A[i]。接下来M行每行3个整数k,x,y,k=1表示查询(此时如果x>y,请交换x,y),k=2表示修改。输出格式对于每个查询指令输出一个整数表示答案。每个答案占

2020-07-26 23:45:36 614

原创 最大数

题目描述给定一个正整数数列 a1,a2,…,an,每一个数都在 0∼p−1 之间。可以对这列数进行两种操作:添加操作:向序列后添加一个数,序列长度变成 n+1;询问操作:询问这个序列中最后 L 个数中最大的数是多少。程序运行的最开始,整数序列为空。写一个程序,读入操作的序列,并输出询问操作的答案。输入格式第一行有两个正整数 m,p,意义如题目描述;接下来 m 行,每一行表示一个操作。如果该行的内容是 Q L,则表示这个操作是询问序列中最后 L 个数的最大数是多少;如果是 A t,

2020-07-26 22:49:05 611

原创 #659 (Div. 2) B. Koa and the Beach (Easy Version DP&&Hard Version 贪心)

题目描述The only difference between easy and hard versions is on constraints. In this version constraints are higher. You can make hacks only if all versions of the problem are solved.Koa the Koala is at the beach!The beach consists (from left to right) of

2020-07-25 11:45:31 1403

原创 #659 (Div. 2) C. String Transformation 1(贪心)

题目描述Note that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter y Koa selects must be strictly greater alphabetically than x (read statement for better understanding). You

2020-07-25 10:17:40 681

原创 Educational Codeforces Round 72 C.The Number Of Good Substrings

题目描述You are given a binary string s (recall that a string is binary if each character is either 0 or 1).Let f(t) be the decimal representation of integer t written in binary form (possibly with leading zeroes). For example f(011)=3,f(00101)=5,f(00001)=1

2020-07-24 22:32:35 247

原创 #582 (Div. 3) D.Equalizing by Division

题目描述The only difference between easy and hard versions is the number of elements in the array.You are given an array a consisting of n integers. In one move you can choose any ai and divide it by 2 rounding down (in other words, in one move you can set

2020-07-24 21:34:31 231

原创 暑期训练第三周第五天

A给你一个有向图,你有k种颜色,要给每一条边上色。要求:上同一种颜色的边不能组成一个环。问:k的最小值,和每条边要上什么颜色。B你的游戏角色有str点力量,int点智力。你有exp个未分配的点,你想让角色的力量大于智力,问有多少种分配方式(分配完要保证力量大于智力)。C一个怪物有x个头,你有n种技能。第i种技能可以打掉怪物d[i]个头,但之后怪物接着会长出h[i]个头来。问能否打败这个怪物,最少要用几次技能。E你有n个物品,每个物品可以免费向左或向右移动2个单位,也可以花一块钱向左或者向右移动

2020-07-24 21:07:24 227

原创 STL函数总结

unique()unique() 位于<algorithm>头文件中,其作用是元素去重,即删除序列中所有相邻的重复元素。其删除元素,只是一个伪去除,只是重新排列了序列中的元素,将相邻的重复元素添加到容器末尾。简单来说,使用 unique() 后,容器的长度没有变,只是元素顺序改变了。其返回值是去重之后的尾地址,减去数组 a 的起始地址后所得到的就是 a 中去重后的元素个数。int a[12]={1,1,1,2,2,3,3,3,4,5,6,6};int len=unique(a,a+12

2020-07-23 22:53:20 394

原创 Educational Codeforces Round 73 D.Make The Fence Great Again(dp)

题目描述You have a fence consisting of n vertical boards. The width of each board is 1. The height of the i-th board is ai. You think that the fence is great if there is no pair of adjacent boards having the same height. More formally, the fence is great if

2020-07-23 18:44:15 254

原创 暑期训练第三周第四天

A这个黑市每种类型的剑有x把,有y个人来到了黑市,每个人要一种相同类型的剑z把。第二天点主发现它第i种类型的剑还剩了a[i]把,求y的最小值和z。B给你一个只包含a和b的字符串s,你可以进行如下操作:选择s中任意位置的一个字符,将它修改成另一个。问:至少要经过多少次的修改,才能使得任意选取一个偶数的长度len,使得s[1-len]中的a和b的数量相等。CDEFGH...

2020-07-23 17:59:21 239

原创 #658 (Div. 2)D.Unmerge(分块+01背包问题)

题目描述Let a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array merge(a,b) of length n+m recursively as follows:If one of the arrays is empty, the result is the other array. That is, merge(∅,b)=b and

2020-07-23 16:52:54 508

原创 #658 (Div. 2) C2.Prefix Flip (Hard Version)

题目描述This is the hard version of the problem. The difference between the versions is the constraint on n and the required number of operations. You can make hacks only if all versions of the problem are solved.There are two binary strings a and b of leng

2020-07-22 22:34:54 439

原创 谜一样的牛

题目描述有n头奶牛,已知它们的身高为 1~n 且各不相同,但不知道每头奶牛的具体身高。现在这n头奶牛站成一列,已知第i头牛前面有Ai头牛比它低,求每头奶牛的身高。输入格式第1行:输入整数n。第2…n行:每行输入一个整数Ai,第i行表示第i头牛前面有Ai头牛比它低。(注意:因为第1头牛前面没有牛,所以并没有将它列出)输出格式输出包含n行,每行输出一个整数表示牛的身高。第i行输出第i头牛的身高。数据范围1≤n≤105输入样例:51210输出样例:245

2020-07-22 18:16:29 483

原创 一个简单的整数问题2(树状数组&&线段树)

题目描述给定一个长度为N的数列A,以及M条指令,每条指令可能是以下两种之一:1、“C l r d”,表示把 A[l],A[l+1],…,A[r] 都加上 d。2、“Q l r”,表示询问 数列中第 l~r 个数的和。对于每个询问,输出一个整数表示答案。输入格式第一行两个整数N,M。第二行N个整数A[i]。接下来M行表示M条指令,每条指令的格式如题目描述所示。输出格式对于每个询问,输出一个整数表示答案。每个答案占一行。数据范围1≤N,M≤105,|d|≤10000,

2020-07-22 16:44:37 444

原创 一个简单的整数问题

题目描述给定长度为N的数列A,然后输入M行操作指令。第一类指令形如“C l r d”,表示把数列中第l~r个数都加d。第二类指令形如“Q X”,表示询问数列中第x个数的值。对于每个询问,输出一个整数表示答案。输入格式第一行包含两个整数N和M。第二行包含N个整数A[i]。接下来M行表示M条指令,每条指令的格式如题目描述所示。输出格式对于每个询问,输出一个整数表示答案。每个答案占一行。数据范围1≤N,M≤105,|d|≤10000,|A[i]|≤1000000000

2020-07-22 15:55:06 992

原创 楼兰图腾

题目描述在完成了分配任务之后,西部314来到了楼兰古城的西部。相传很久以前这片土地上(比楼兰古城还早)生活着两个部落,一个部落崇拜尖刀(‘V’),一个部落崇拜铁锹(‘∧’),他们分别用V和∧的形状来代表各自部落的图腾。西部314在楼兰古城的下面发现了一幅巨大的壁画,壁画上被标记出了N个点,经测量发现这N个点的水平位置和竖直位置是两两不同的。西部314认为这幅壁画所包含的信息与这N个点的相对位置有关,因此不妨设坐标分别为(1,y1),(2,y2),…,(n,yn),其中y1~yn是1到n的一个排列。

2020-07-22 15:44:19 666 4

原创 #590 (Div. 3) D.Distinct Characters Queries (树状数组)

题目描述You are given a string s consisting of lowercase Latin letters and q queries for this string.Recall that the substring s[l;r] of the string s is the string slsl+1…sr. For example, the substrings of “codeforces” are “code”, “force”, “f”, “for”, but n

2020-07-22 10:51:29 359

原创 [#590 (Div. 3)]暑期训练第三周第二天

A你有1-6号六种模型:给你一个只包含上述六种模型的图,长度为n,宽为2,问你能否通过旋转图转的一些模型,使得这些模型连成一条线从左上角到右下角。如:Bpi(n)是一个 [i,1,2…,i-1,i+1,…,n] 序列,给你一个包含m个数的数组a[]。pos(p,x)为x在p数组中的位置,如pos(p2(4),2)=1。f( p )=sum| pos(p,a[i])-pos(p,a[i+1]) |。求f(p1(n)),f(p2(n)),…,f(pn(n))。CDEF感想...

2020-07-21 16:54:30 922

原创 Educational Codeforces Round 74 D.AB-string(思维+找规律)

题目描述The string t1t2…tk is good if each letter of this string belongs to at least one palindrome of length greater than 1.A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes,

2020-07-20 20:59:25 385

原创 [Educational Codeforces Round 74]暑期训练第三周第一天

A给你一棵含有n个点的树,问这棵树最大的子树包含多少个点。BC给你两个数x和y,问能否让x减去某一个素数多次最后使得x变成y。DEF在x>0的地方,有n个怪物,每个怪物的坐标为x[i]。x<=0的地方,全部都是陷阱。你可以向x轴的任意地方发射导弹,假设你向y点发射了导弹,那么在y点的怪物将会被炸死,在y点右边的怪物将会向右移r(即x[i]+r),在y点左边的怪物将会向左移(即x[i]-r)。如果怪物的位置x[i]<=0了,那么怪物将会被陷阱杀死。问最少要发射多少次导弹才能将

2020-07-20 18:07:51 256

原创 #656 (Div. 3)F. Removing Leaves(贪心)

题目描述You are given a tree (connected graph without cycles) consisting of n vertices. The tree is unrooted — it is just a connected undirected graph without cycles.In one move, you can choose exactly k leaves (leaf is such a vertex that is connected to on

2020-07-19 16:26:23 439

原创 #656 (Div. 3)E. Directing Edges(拓扑序列)

题目描述You are given a graph consisting of n vertices and m edges. It is not guaranteed that the given graph is connected. Some edges are already directed and you can’t change their direction. Other edges are undirected and you have to choose some direction

2020-07-19 15:57:30 777 3

原创 暑期训练第二周第三天

今天的训练还是复习上周做过的习题,因此我就直接写感想了。感想刚开始的时候,其实我并不是很理解问什么要花这么长的时间来复习前面做过去的题目,有这时间做两道新题多好呢。但后来我又仔细的想了想,如果没有练习的话,这些空余的时间我可能会去学一下新东西,做做题,但绝对不可能去复习之前的题目。那么对于老师来说:要想让我们都复习,最优效的办法还是拿出时间来统一的把之间做过的题目在复习一遍。站在老师的立场上,这确实是合理的,要是我是老师我可能也会这么做。但是复习之前的题目有什么作用呢?是要重新回忆起这个题的思路,这个

2020-07-16 08:11:25 268

原创 暑期训练第二周第二天

A给你一个数为x,你可以进行两个操作:让x减一,如果x为偶数,那么让x乘3/2.问x能否通过操作变为y。这个题比较水,不写思路了。过程: 这个题虽然水,但一开始我用的方法是错的,这就导致错了几次。最后我换了个方法才过的。B给你一个数组,数组中包含1-n这n个数(但没有顺序)。你可以进行如下操作:交换两个相邻位置的数。但交换过的位置不能再次交换。问如何操作才能使得该序列字典序最小。B. Minimize the Permutation这个题做了三遍了,都快背过了。。。C给出一个路径(由UDR

2020-07-14 23:31:38 286

原创 Educational Codeforces Round 91 D. Berserk And Fireball

题目描述There are n warriors in a row. The power of the i-th warrior is ai. All powers are pairwise distinct.You have two types of spells which you may cast:Fireball: you spend x mana and destroy exactly k consecutive warriors;Berserk: you spend y mana, c

2020-07-13 10:49:14 577

原创 #598 (Div. 3) F.Equalizing Two Strings

题目描述You are given two strings s and t both of length n and both consisting of lowercase Latin letters.In one move, you can choose any length len from 1 to n and perform the following operation:Choose any contiguous substring of the string s of length l

2020-07-12 22:16:32 565 2

原创 Educational Codeforces Round 75 E2. Voting(堆)

题目描述The only difference between easy and hard versions is constraints.Now elections are held in Berland and you want to win them. More precisely, you want everyone to vote for you.There are n voters, and two ways to convince each of them to vote for yo

2020-07-12 21:08:49 341

原创 #598 (Div. 3) E.Yet Another Division Into Teams(dp)

题目描述There are n students at your university. The programming skill of the i-th student is ai. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has 2⋅105 students r

2020-07-12 20:10:27 357

原创 Educational Codeforces Round 77 E.Tournament

题目描述You are organizing a boxing tournament, where n boxers will participate (n is a power of 2), and your friend is one of them. All boxers have different strength from 1 to n, and boxer i wins in the match against boxer j if and only if i is stronger th

2020-07-12 11:17:01 363

原创 #595 (Div. 3) D2.Too Many Segments (hard version)(数据结构:set的应用)

题目描述The only difference between easy and hard versions is constraints.You are given n segments on the coordinate axis OX. Segments can intersect, lie inside each other and even coincide. The i-th segment is [li;ri] (li≤ri) and it covers all integer poin

2020-07-11 23:40:11 417

原创 #595 (Div. 3) C2.Good Numbers (hard version)(三进制)

题目描述The only difference between easy and hard versions is the maximum value of n.You are given a positive integer number n. You really love good numbers so you want to find the smallest good number greater than or equal to n.The positive integer is cal

2020-07-11 21:54:41 328

原创 #595 (Div. 3) B2.Books Exchange (hard version)(模拟+找规律)

题目描述The only difference between easy and hard versions is constraints.There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the pi-th kid (in case of i=pi the kid will give his book to himself

2020-07-11 21:04:10 399

原创 [#595 (Div. 3)]暑期训练第六天

A给你一个整数n,要求你找到一个大于等于n的最小的好数m。好数:一个数是好数如果这个数能拆成多个3n相加(所有的n不能两两相等)。B有n个人,每个人的能力为a[i],你想将这n个人分成好几队。分组的规则如下:如果有两个人的能力值的差的绝对值等于1(| a[j]-a[i] |==1),那么这两个人不能在同一队中。问最小能分成多少队。C在x轴上给出n条线段,每条线段都给出了左右端点l[i]和r[i]。如果有某个点上覆盖了多于k条线段,那么这个点就是一个坏点。问:我们最少要删除多少条线段,使得x轴

2020-07-11 20:41:36 365

原创 Educational Codeforces Round 75 D. Salary Changing(二分)

题目描述You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2).You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from li to

2020-07-10 23:08:30 332

空空如也

空空如也

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

TA关注的人

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