
思维题
文章平均质量分 56
平时练习题
(xsj)
模拟只会猜题意
贪心只能过样例
DP一般看规律
数论只会gcd
计算几何瞎暴力
图论只会匈牙利
数据结构没学过
字符串只能干输入
展开
-
codeforces 1526 C
题面题意给你一个长度为n的序列a,你的初始生命值为0,你可以选择加上ai,但前提是保证在任何时刻生命值不小于0. 求最多能加多少个值。C1版本的的n为2000,C2版本的n为20000C1题解C1的n只有2000,可以直接用dp来做,f[i] [j] 表示在前 i 瓶中选择了 j 瓶的最大价值,就可以由 max ( f[i-1] [j] , f[i-1] [j] +a[i] ) 得到C1代码#include<bits/stdc++.h> using namespace st原创 2021-06-03 21:09:49 · 468 阅读 · 0 评论 -
codeforces 1526 B.I Hate 1111
题面题意给你一个数,判断它能否由11,111,1111,11111 …组成题解(打表)我们通过dfs打表发现,大于10000的数都是可以由题中所给条件组成的,所以我们只需要存放10000的数进行判断即可。代码#include<bits/stdc++.h> using namespace std;typedef long long ll;const int N=1e5+10;const int maxn=10000; int t,n;int arr[]={11原创 2021-06-03 20:50:30 · 528 阅读 · 0 评论 -
codeforces 1529 D.Kavi on Pairing Duty
题面题意给你一个n,坐标上有2n个点,间距为1,让你求出满足题意得方案数。每两个点连接成一条线段,要求线段两两之间要么长度相等,要么一个线段被另一个线段包含题解(找规律)设ai表示,n=i 时有多少方案数当n=1时,有1种情况,就是直接两个点连起来当n=2时,有3种情况先考虑存在包含,将最外的两个点连起来,这种情况下就递归回了a1,然后再考虑不存在包含,每遇到一个点连一条线,发现可以 ; 每遇到两个点连一条线,发现可以,方案数+2;当n=3时,6种情况原创 2021-06-02 21:50:00 · 513 阅读 · 0 评论 -
codeforces 1529 B.Sifid and Strange Subsequences
题面题意给定一个序列,找一个最长的子序列,满足对于子序列的任意两个数ai,aj,(1<=i<j<=k),使得 | ai - aj | >= MAX (子序列中最大的数)题解对于子序列,如果都是负数或者0一定成立,因为绝对值不可能小于0,所以要想最长,就要包含所有的负数和0,对于正数,子序列中最多存在一个,因为如果大于一个,两个整数的绝对值肯定小于本身。所以只需要看原来序列中最小的正数,是否满足条件即可,两个负数的差值越小,那么差值绝对值就越小,所以给原序列原创 2021-06-02 16:01:32 · 217 阅读 · 0 评论 -
codeoforces 1467 B Hills And Valleys (枚举)
题面题意题解一开始想的是分情况讨论,比如当修改一个值后会影响几个波峰波谷的变化,又会增加几个新的波峰波谷,其实不用2.因为只能改变一个值,所以我们直接枚举改变的值,改变后最优的值肯定是和左右端点相等的,对于枚举的每个点,我们只需要判断一下等于左端点减少的峰谷多还是等于右端点峰谷减少的多就可以了代码#include<bits/stdc++.h>using namespace std;const int N = 1e6 + 10;int t, n;int a[N]原创 2021-02-24 13:19:03 · 127 阅读 · 0 评论 -
Codeforces Round #648 (Div. 2) C 1365------最大偏移
原题链接After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size n. Let’s call them a and b.Note that a perm原创 2020-11-25 10:59:31 · 171 阅读 · 0 评论 -
西南科技大学第十六届ACM程序设计竞赛暨绵阳市邀请赛 A 找规律
题面题解理解题意有问题,这个题就是说每一次洗牌都会交换顺序,牌的顺序会形成一个环,就是经过13次顺序就会变回最初的状态那么题中给出两次变换后的位置,我们可以知道,2 * 9 -13 = 5 ,变换9个两次就相当于变换了5个次代码#include<bits/stdc++.h>using namespace std;const int N=14;int main() { string a[N], b[N], c[N]; while (cin >原创 2021-01-30 20:17:02 · 354 阅读 · 0 评论 -
codeforces 1478 C Nezzar and Symmetric Array
题面题意给定一个长度为2n的序列d,问能否通过上述公式得到a序列,输出“YES”/“NO”, a序列中必须成对出现相反数,ai = - aj ,而且不能相同题解昨天的题,注意看数据范围,找规律,一定不要漏掉条件啊因为a数组是成对的相反数,并且d是根据a的绝对值之和求出,所以d中的值也是成对出现的(第一个判断条件)对于任意一个di ,假设 i = 1 ,d1 = | a1 - a1 | + | a1 - a2 | + | a1 - a3 | + | a1 - a4| … 假设a1 = -a原创 2021-01-29 12:18:30 · 357 阅读 · 0 评论 -
codeforces 1475 F Unusual Matrix (构造)
题面题意给你 a , b 两个矩阵,问通过翻转(0变1,1变0)能否使a变成b翻转必须是整行或者整列翻转思路像这种翻转题,一般先看规律,我们会发现,每行或每列只需要翻转0或者1次,因为翻转2次相当于没有翻转,翻转3次相当于翻转1次;还有就是翻转的顺序不会影响最终的结果我们可以定义一个二维矩阵,存放a和b哪个位置需要翻转,如果不同就为1,相同为0,我们最终的目标就是将c矩阵全部变为0,就代表a和b都相同了我们固定第一列,使其全部变为0,就是当每行的第一个数不为0,就将这行进行翻原创 2021-01-28 10:58:48 · 250 阅读 · 0 评论 -
codeforces 1475 C Ball in Berland
原题链接题意有n个男的m个女的,还有k对关系(a,b)表示第a个男的可以和第b个女的跳舞.现在要求你从k对关系里选出两对不干扰的男女,不干扰即是指同一个人不能出现在两对关系里,问选出两对关系的方案数有多少个.思路我们可以选出一对,来枚举另一对,然后求出总和,因为枚举也会计算另一对,所以结果/2如何枚举另一对,对于另一对,不能和a,b相同,即不能与a,b有关,可以利用补集来求,(a,b)在k对关系中,统计与a出现的次数cnta,b出现的次数cntb,那么cnta+cntb-1就是除去要枚原创 2021-01-27 18:01:34 · 377 阅读 · 0 评论 -
codeforces 1038 D 相对贡献值
原题链接题意有n只史莱姆,每只史莱姆有一个分数,每次一只史莱姆可以吞掉左边的或者右边的史莱姆(要是有的话),然后ta的分数会减去被吞的史莱姆的分数,问最后剩下的史莱姆分数最大为多少思路我们分类讨论,然后进行总结假如有正有负,那么我们可以用负数减去正数,让其越减越小,但绝对值越大,最后用正数减去,就能得到最大的值,这样我们虽然一直在减来减去,但是绝对值一直没有变,最后输出的答案也是“没有损耗”的,所以,假如有正有负,最后的答案就应该是所有数绝对值的和。假如全是正数,那么我们通过刚才的推理考原创 2021-01-23 17:06:39 · 105 阅读 · 0 评论 -
codeforces 1462 D Add to Neighbour and Remove
原题链接题意给你一个长度为n的数组,每次操作相邻的两个数,把他们合并(两数相加),然后放在原来的位置上,问多少次操作后,可以使数组中的所有数都相等(有可能最后合并的只剩一个数)思路每次只能合并两个相邻的数,所以我们最终的数组的每一个数字,一定是原序列中一段连续的数字的和组成的,而且是按序的,不重复的我们就可以把问题转化为:把序列分成若干连续的段,使得每一段内包含的数字和相同,求分段数量的最大值,也就是操作的最小次。3.接下来我们就可以枚举第一段的数量,根据第一段的数量,就可以确定第一段的原创 2021-01-22 21:25:57 · 178 阅读 · 0 评论 -
codeforces 1462 C Unique Number
原题链接题意t 组样例,每组一个x,问你能否构造出一个数a,使得a个各位数相加等于x,并且a的各位数都不相同,在满足这两个条件的情况下,使得a最小思路我们可以发现,答案中不可能有0,因为0放在第一位不符合,放在别的地方只会增大数,不会对构造做出任何贡献所以能用的数只有1–9,1+2+3+4+5+6+7+8+9=45,因为要满足每一位都不相同,所以x最大位45然后剩余直接枚举即可AC代码#include<bits/stdc++.h>using namespace st原创 2021-01-22 19:13:03 · 248 阅读 · 0 评论 -
cf 1471 B 最大贡献
原题链接题意t 组样例 ,每组有长度为 n 的数组 a 和 一个数 x ,下一行 输入数组 a如果a[i]%x==0 ,那么就将 x个 a[i]/x 放在数组的末尾,然后继续这样的操作,直到a[i]%x!=0时停止求数组的和思路1.昨天打的比赛,其实题目很简单,考虑一下每个数的最大贡献值,然后直接模拟就好,但是不是直接暴力模拟啊2.拿第二个样例来说 ,[4,6,8,2] —>[4,6,8,2,2,2]---->[4,6,8,2,2,2,3,3]—>[4,6,8,2,原创 2021-01-06 08:47:01 · 160 阅读 · 0 评论 -
cf 845 B
原题链接题意思路1.一开始做的想法是错误的,然后wa了好几次,最后看样例才ac了2.我们知道,最多也就操作3次,每次操作的最大程度只能是将 这个数变为9或者0,这样才能是我们的结果最优化3.分情况,假设前三个数的和为sum1,后三个数的和为sum2sum1>sum2 : 前面的数字要变小,后面的数字要变大,才能的到最终的结果,所以我们让前三个数变到0,后三个数变到9,将其最大化利益放入新数组之后排序,当sum1-sum2不为0时,每次取最大利益进行计算sum2>sum1原创 2021-01-03 15:17:07 · 163 阅读 · 0 评论 -
codeforces 1364 C
原题链接题意思路1.根据题意可知,不可能输出-12.因数组a是非递减序列,若a[i] != a[i-1],则b[i] = a[i-1] ;3.a[i]==a[i-1],那么b[i]可以在[0,n]中未占用的数据中,自小到大,进行选取。AC代码#include<bits/stdc++.h>using namespace std;const int N=1e6+10;int n;int a[N],b[N],vis[N],c[N],index;int main(原创 2020-12-28 21:19:03 · 230 阅读 · 0 评论 -
Codeforces Round #688 (Div. 2) 1453 B
原题链接Gildong has an interesting machine that has an array a with n integers. The machine supports two kinds of operations:Increase all elements of a suffix of the array by 1.Decrease all elements of a suffix of the array by 1.A suffix is a subsegment (c原创 2020-12-06 09:55:55 · 185 阅读 · 0 评论 -
Codeforces Round #404 (Div. 2) C 785(java)
原题链接Anton likes to listen to fairy tales, especially when Danik, Anton’s best friend, tells them. Right now Danik tells Anton a fairy tale:“Once upon a time, there lived an emperor. He was very rich and had much grain. One day he ordered to build a huge原创 2020-11-23 19:54:07 · 145 阅读 · 0 评论 -
Codeforces Round #655 (Div. 2) 1372 B java
原题链接In Omkar’s last class of math, he learned about the least common multiple, or LCM. LCM(a,b) is the smallest positive integer x which is divisible by both a and b.Omkar, having a laudably curious mind, immediately thought of a problem involving the LC原创 2020-11-17 18:13:50 · 135 阅读 · 0 评论 -
Codeforces Round #651 (Div. 2) C 1370-----java
原题链接Ashishgup and FastestFinger play a game.They start with a number n and play in turns. In each turn, a player can make any one of the following moves:Divide n by any of its odd divisors greater than 1.Subtract 1 from n if n is greater than 1.Diviso原创 2020-11-16 22:09:00 · 137 阅读 · 0 评论 -
Codeforces Round #651 (Div. 2) B 1370 ——java
原题链接Ashish has an array a of consisting of 2n positive integers. He wants to compress a into an array b of size n−1. To do this, he first discards exactly 2 (any two) elements from a. He then performs the following operation until there are no elements le原创 2020-11-16 21:09:14 · 113 阅读 · 0 评论 -
Codeforces Round #661 (Div. 3) 1399 C题 题解(java)
原题链接There are n people who want to participate in a boat competition. The weight of the i-th participant is wi. Only teams consisting of two people can participate in this competition. As an organizer, you think that it’s fair to allow only teams with the原创 2020-11-15 08:45:51 · 252 阅读 · 0 评论 -
Codeforces Round #666 (Div. 2)——1397C (java)
题目链接You are given an array a of n integers.You want to make all elements of a equal to zero by doing the following operation exactly three times:Select a segment, for each number in this segment we can add a multiple of len to it, where len is the lengt原创 2020-11-11 18:33:13 · 158 阅读 · 0 评论 -
Codeforces Round #667 (Div. 3) 1409C
题目链接C. Yet Another Array RestorationWe have a secret array. You don’t know this array and you have to restore it. However, you know some facts about this array:The array consists of n distinct positive (greater than 0) integers.The array contains two e原创 2020-11-10 18:55:39 · 184 阅读 · 0 评论