自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Codeforces Round #765 (Div. 2)

从位运算出发,我们找出k的最高位1,设为x,然后把x上面的位相同的分为一组,我们可以发现,x前面的位只要不同,怎么异或都会比k大,然后每个前面位相同的组又最多能出两个数字,因为他们前面都是一样的,异或后只能看x位以及x位后面,而且由于鸽巢原理,在第x位三个数两两异或肯定有一对x位为0,这时候就是trie树的板子题了,要找出是否有两个数字异或大于等于k,有就这一个分组有两个贡献,否则为一个。我们可以发现两个数字相同的时候,两个数字能有最长的前缀长度为前面数字的前缀,最长的后缀长度为后面数字的后缀。

2022-09-16 20:57:50 115 1

原创 Codeforces Round #764 (Div. 3)

给定n个点m条边,需要你找出一个最小的边权或生成树。我们可以用克鲁斯卡尔算法,先把边权排序,看最少需要到哪一条边,然后把所有边有最大边的最高位1的都置为0,而且答案要加上这一位1的贡献,因为怎么跑都最小要用到这个一,把所有有这一位1的置为0,重新排序重新做最小生成树,复杂度为排序nlogn加上循环31次。给定n和m代表字符长度和字符串数量,要求组成m个回文字符串,求m个中长度最短,先求出字母对,分配给m个字,然后剩下的字符看能不能够再分m个,能就最小值再加一(如果字母对没用上也要放在第二步中)

2022-09-16 20:54:21 120

原创 Good Bye 2021: 2022 is NEAR

给定n个数,要求你从中尽可能少的删除数字,让他们的每个大于等于2的连续子序列平均数大于等于x,还是之前的结论,任意序列都可以分解为2和3,只要2和3满足,大的肯定能满足,然后我们看选不选一个数字,就看它和他前面的数字一个和两个能不能连起来,如果不行就抛弃这个数字,让后面和前面断开。给一个字符串要求选一个前缀并把前缀翻转后和前缀连接,输出字典序最小的结果。给一个字符串s和一个字符串t,每次操作是把s的任意一个字符和它相邻的字符换位置,求最少的更换的次数使得s的字典序比t小,没有操作的话输出-1。

2022-09-16 20:53:36 203

原创 Hello 2022

给定一个2n*2n的矩阵 然后我们要把i=n+1里面,走过的点就是我们的全部花费。然后我们会发现,需要把i>=n+1&&j>=n+1的贡献先算上,然后要有一个入口进入就能慢慢的全部移动进去,分别有八个点是能进去的。我们在找到一个更小的l时,就要更新左花费并且把左右都是一个同一段花费置成inf,把左边界更新,在找到一个更大的r时,就要更新右花费并且把左右都是一个同一段花费置成inf,把右边界更新。last==now直接判断1~n是不是大于等于0。

2022-09-16 20:52:11 83

原创 练练思维补题

补题

2022-09-16 20:49:17 45

原创 Codeforces Round #803 (Div. 2) D和E

cf记录

2022-07-04 21:40:16 191

原创 SCAU2022春季第一场

2022春季第一场A题意:现在银行有n堆宝石按顺序排列,每堆宝石的个数为ai。银行在间隔m秒之后会检查一下相邻两堆宝石的加和有没有改变,如果改变了就会报警。问你在k次m秒之内,最多能偷取多少的宝石。题解:先模拟一下把第一堆移动一个到第二堆。这样第一堆和第二堆的总和不变,但是第二堆和第三堆的总和加了一,如果这时候第三堆后面没有宝石了的话,我们就可以把第三堆中偷走一个,使得系统不会报警。但如果第三堆后面有第四堆的话,我们就必须把第二堆左移一个或把第三堆右移一个才不会报警,我们不会尝试把第二堆左...

2022-03-24 14:32:46 378 1

原创 acwing 奇偶游戏

题解:用并查集处理到队头1数量的奇偶性,每次合并时候处理,具有传递性,合并ab的时候,找到a的祖先节点pa,pa到b的奇偶性不能直接得出,但能由a到b的奇偶性和a到pa的奇偶性得出,比如a到pb为偶,a到b为偶,得出a到b为偶。再由pa到b和b到pb得出pa到pb奇偶性。#include<bits/stdc++.h>using namespace std;unordered_map<int,int> Hash;const int N=20010;int p[N];..

2021-09-26 17:00:33 89

原创 Hamburgers CodeForces - 371C

题解:给定bsc的初始数量,然后给价格和配料要求,求最多做多少个汉堡包题解:直接二分#include<iostream>#include<cstdio>#include<map>#include<algorithm>#include<cstdio>#include<vector>#include<stack>#include<queue>#include<dequ...

2021-09-19 23:17:56 115

原创 Ice Skating CodeForces - 217A

题意:给定n个点,然后给每个点能去到的另外两个点,问最小加几条边能使全部点连起来题解:直接dfs(1),然后每次重新dfsans就加一#include<iostream>#include<cstdio>#include<map>#include<algorithm>#include<cstdio>#include<vector>#include<stack>#include<queu...

2021-09-19 23:14:55 133

原创 Little Elephant and Problem CodeForces - 220A

题意:给定一个数组,看能不能交换一次之后让数组排序成功题解:直接建一个b数组sort后,看和a不同位置的个数有没有大于2。#include<iostream>#include<cstdio>#include<map>#include<algorithm>#include<cstdio>#include<vector>#include<stack>#include<queue>...

2021-09-19 23:09:31 68

原创 Pashmak and Buses CodeForces - 459C

题意:给定n个学生,k辆车和d天,要求每个学生在d天内每天找一辆车乘坐,不能有任意两个学生在d天内选择都一样。题解:共有k的d次方总选法,我们可以知道当k的n次方大于n时无解,然后每次我们从按照编号给他们d天内的车安排一个序列就行了#include<iostream>#include<cstdio>#include<map>#include<algorithm>#include<cstdio>#include<v...

2021-09-18 13:17:56 178

原创 Bombs CodeForces - 350C

题意:给定n个炸弹和炸弹的坐标,要求把所有炸弹拆除而且拆炸弹时不能踩到其它炸弹题解:直接按路径长度排序然后拆就行了#include<iostream>#include<cstdio>#include<map>#include<algorithm>#include<cstdio>#include<vector>#include<stack>#include<queue>#inc...

2021-09-18 12:18:43 84

原创 Xenia and Weights

题意:给定一个长度为10的字符串,第i位上为1表示有重量为i的砝码,然后我们需要进行m次加码,左右轮流加,要求每次加的砝码和上次不同而且加完后当前加的边应比另外一边重。题解:数据小,直接dfs搜#include<iostream>#include<cstdio>#include<map>#include<algorithm>#include<cstdio>#include<vector>#include&...

2021-09-16 15:46:54 107

原创 Hexadecimal‘s Numbers

题意:给一个十进制的数字n,问1~n有多少个数字是二进制能表示出来的题解:多种解法,我写了个枚举长度二进制的和dfs的#include<iostream>#include<cstdio>#include<map>#include<algorithm>#include<cstdio>#include<vector>#include<stack>#include<queue>#i...

2021-09-15 22:12:47 125

原创 Arithmetic Progression

题意:构造等比数列#include<iostream>#include<cstdio>#include<map>#include<algorithm>#include<cstdio>#include<vector>#include<stack>#include<queue>#include<deque>#include<cstring>#include...

2021-09-15 11:00:39 60

原创 Pocket Book

题意:给n个长度为m的字符串,算出能组成多少个不同的字符串,只能出现在原来的下标题解:算每一位不同字符的数量相乘就行了#include<iostream>#include<cstdio>#include<map>#include<algorithm>#include<cstdio>#include<vector>#include<stack>#include<queue>...

2021-09-14 17:26:06 120

原创 acwing 子序列

题解:如果有答案必定长度为3 子序列答案为一个山峰或者山谷的形状#include<bits/stdc++.h>using namespace std;int a[100010];int l[100010],w[100010]; //l表示当前点为最低点,左边比他大的数的下标,没有就是0 w表示最高点int main(){ int n; cin>>n; for(int i=1;i<=n;i++) cin>>a[i...

2021-09-13 23:58:05 47

原创 acwing 截断数组

题解:枚举第三刀的点,然后i-2枚举第一刀的点(存在cnt中)如果当前枚举的点为第三刀,答案就加上cnt。#include<bits/stdc++.h>using namespace std;int a[100010];long long ans,cnt;int main(){ int n; cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; ...

2021-09-13 23:54:12 135

原创 Buds Re-hanging

题意:给定一颗树,定义一种结构为花蕊(有子节点而且子节点都是叶子),能有一种操作把花蕊断开,然后重新拼接后使得叶子节点最少。题解:把树拆成一个个不能分解的花蕊节点,答案初始为一个根节点,然后每个花蕊的贡献为叶子节点-1,统计所有花蕊的贡献就行了。#include<iostream>#include<cstdio>#include<map>#include<algorithm>#include<cstdio>...

2021-09-13 20:42:58 89

原创 Gargari and Bishops

题意:选两个点,这两个点的贡献为他们对角线和反对角线的数字总和。题解:贪心,容易发现i+j分奇偶讨论能把两个对角线错开。#include<iostream>#include<cstdio>#include<map>#include<algorithm>#include<cstdio>#include<vector>#include<stack>#include<queue>#...

2021-09-12 19:03:00 46

原创 Fixing Typos

题意:给一个字符串,删除若干个字符使字符串满足两个要求;要求一:连续字符不能出现超过两个,例如aaa bbbb 要求二:不能有连续两个一对的字符出现 例如 aabb题解:贪心,出现一个连续长度大于等于2的,判断上次输出有没有两个,有的话就输出一个,没有就两个。#include<iostream>#include<cstdio>#include<map>#include<algorithm>#include<cstdio...

2021-09-12 18:53:34 52

原创 Hacking Cypher

题意:给一个很大的数字n,要求分成两半,左右两半同时能被给的a和b整除。题解:同余定理,由于a和b都是小于1e8的数字,在加上一个数字的时候,取他们模a,b的余数进行计算就行了。#include<iostream>#include<cstdio>#include<map>#include<algorithm>#include<cstdio>#include<vector>#include<s...

2021-09-12 18:35:42 71

原创 D. Take a Guess

题意:给一个长度为n的数组,要求不多于2n次询问,每次询问可以问任意ai,aj的and或者or,要求输出数组的第k大题解:a+b=(a|b)+(a&b) 可以先得出a1和a2~an的和,然后求a2+a3 2*a1=(a1+a2)+(a1+a3)-(a2+a3);得出a1后就能得出其他数了。然后存进输出排个序就行。#include<iostream>#include<cstdio>#include<map>#include<algo...

2021-09-07 00:16:44 98

原创 CF#742 (Div. 2)Expression Evaluation Error

题意:给定n,m;把n拆成m个整数,要求这m个整数在11进制下值和最大。思路:我们可以观察到m范围1~100 所以可以暴力求解进位,要数字在11进制下最大的和,肯定不能影响高位的数字,因为你拆的时候是在十进制下的,你把他拆成地位,相加的时候要11才能进位,等于少了一位 比如10拆成5和5在十一进制相加变成A(10),但在十一进制下10和0相加变成10(11)。所以我们贪心的保留高位就够了。#include<iostream>#include<cstdio>#...

2021-09-06 14:03:47 114

原创 C. Compressed Bracket Sequence

William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integersc1,c2,…,cnc1,c2,…,cnwhereciciis the number of consecutive brackets "(" ifiiis an odd number or the number of con...

2021-09-05 22:32:31 198 1

原创 Palindrome Transformation

Nam is playing with a string on his computer. The string consists ofnlowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down.There i..

2021-09-04 11:33:37 56

原创 Valera and Tubes

Valera has got a rectangle table consisting ofnrows andmcolumns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of rowxa...

2021-09-04 11:01:40 105

原创 Beautiful Sets of Points

Manao has invented a new mathematical term — a beautiful set of points. He calls a set of points on a planebeautifulif it meets the following conditions:The coordinates of each point in the set are integers. For any two points from the set, the distan..

2021-09-03 21:06:32 63

原创 C. Table Decorations

You haverred,ggreen andbblue balloons. To decorate a single table for the banquet you need exactly three balloons. Three balloons attached to some table shouldn't have the same color. What maximum numbertof tables can be decorated if we know number...

2021-09-03 19:51:50 361

原创 D. Roman and Numbers

Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to n

2021-09-03 19:26:06 149

原创 489C - Given Length and Sum of Digits...

C. Given Length and Sum of Digits...time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a positive integermand a non-negative integers. Your task is to find the smallest and the...

2021-09-03 15:27:27 50

原创 acwing 217.绿豆蛙的归宿

给出一个有向无环的连通图,起点为1,终点为N,每条边都有一个长度。数据保证从起点出发能够到达图中所有的点,图中所有的点也都能够到达终点。绿豆蛙从起点出发,走向终点。到达每一个顶点时,如果有KK条离开该点的道路,绿豆蛙可以选择任意一条道路离开该点,并且走向每条路的概率为1/K。现在绿豆蛙想知道,从起点走到终点所经过的路径总长度的期望是多少?输入格式第一行: 两个整数N,M,代表图中有N个点、M条边。第二行到第1+M 行: 每行33个整数a,b,c代表从a...

2021-09-02 14:59:47 99

空空如也

空空如也

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

TA关注的人

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