![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
思维
文章平均质量分 88
Aloof__
笔记是记忆的缓冲
展开
-
2020 CCPC - 网络赛 1011 3x3 Convolution
3x3 ConvolutionProblem DescriptionGiven ann×nmatrixAand a3×3matrixK. These two matrices are very special : they are both non-negative matrices and the sum of all elements in matrixKis 1 (In order to avoid floating-point error, we will give m...原创 2020-09-21 11:44:08 · 615 阅读 · 2 评论 -
Codeforces Round #668 (Div. 2) Balanced Bitstring&Tree Tag
C - Balanced Bitstring题意:给你一个二进制字符串s,里面可能会包含 “?" ;”?“可以修改成0或者1;现在给你一个k,问s的任意长度与为k的子串能否满足以下条件:长度为k的子串中0和1的数量相等,都是;思路:首先要发现一个规律 s[i]==s[i+k] ,以为只有这样才能满足上述条件;然后字符串s从位置k开始只要遇见”?“直接跳过,遇见不是”?“的要满足下面条件:若s[i%k]!="?",则s[i%k]!=s[i];如果等于那就不合法;如...原创 2020-09-13 14:04:41 · 161 阅读 · 0 评论 -
Codeforces Round #665 (Div. 2) A~D
又是掉分的一晚上~~~~题解也忘了补了A - Distance and Axis画个坐标轴理解下,B如果在OA中间的话,那么|OB-OA|的范围一定小于n,并且奇偶性和m相同;如果k>n的话,那么B一定和A重合,并且在k上#include <bits/stdc++.h>using namespace std;typedef long long ll;const int N=2e5+7;int main(){ int t; cin >>t; w..原创 2020-08-23 17:55:04 · 135 阅读 · 0 评论 -
Codeforces Global Round 10 A~D
A - Omkar and Password给一个序列,每次操作可以合并两个相邻但不相等的数,问要想把序列变成无法继续操作的序列,至少需要操作几次;思路就是 序列中的每一个凹点都要变成和他距离最近的凸点一样高,并且凹点要在凸点的右侧,相当于存在 a[i] <a[i-1] 的话,加上两者的差即可;#include <bits/stdc++.h>using namespace std;const int N=2e5+7;int a[N];int main(){ i..原创 2020-08-20 21:19:24 · 189 阅读 · 0 评论 -
Educational Codeforces Round 93 (Rated for Div. 2) A~D
A - Bad Triangle因为序列是非单调递减的,那么只需要判断序列的前两个数(最小的两个数)和序列的最后一个数(最大的一个数)能否构成三角形即可;#include <bits/stdc++.h>using namespace std;int a[50005];int main(){ int t; cin >>t; while(t--) { int n; cin >>n; for(int i=1;i<=n;i++) ci.原创 2020-08-19 22:50:24 · 190 阅读 · 0 评论 -
Codeforces Round #660 (Div. 2) A~C
目录A. Captain Flint and Crew RecruitmentB. Captain Flint and a Long VoyageC. Uncle Bogdan and Country HappinessA. Captain Flint and Crew Recruitment思路:比较小的前几个类素数: 6 10 14 15 21挑选三个类素数,如果第四个素数和前三个重复则不满足条件,可以对其中的一个类素数进行调整,使得第四个数成为类素数;...原创 2020-08-16 17:58:51 · 165 阅读 · 0 评论 -
Codeforces Round #662 (Div. 2) A~C
A. Rainbow Dash, Fluttershy and Chess Coloring思路:模拟一下会发现规律:如果格子边长是n,那么操作次数就是(n/2)+1#include <bits/stdc++.h>using namespace std;const int N=1e6+7;typedef long long ll;int main(){ int t; cin >>t; while(t--) { ll n; cin &..原创 2020-08-14 17:44:18 · 156 阅读 · 1 评论 -
Codeforces Round #664 (Div. 2) A~D
A. Boboniu Likes to Color Balls#include<bits/stdc++.h>using namespace std;int main(){ int t; cin>>t; while(t--) { int a,b,c,d; cin>>a>>b>>c>>d; int num=0; if(a&1) num++; if(b&1) num+.原创 2020-08-13 10:03:43 · 365 阅读 · 0 评论 -
Codeforces Round #663 (Div. 2) A~D
目录A. Suborrays(思维)B. Fix You(思维)C. Cyclic Permutations(思维,排列组合)D. 505(DP,前缀和)A. Suborrays(思维)思路:线性输出就行了;#include <bits/stdc++.h>using namespace std;int a[100010];int main(){ int t; cin >>t; while(t--) { int n;...原创 2020-08-11 22:44:01 · 193 阅读 · 0 评论 -
2020 杭电多校第六场(Multi-University Training Contest 6)
Little Rabbit's Equation思路:首先对于每个式子,暴力枚举2~16每个进制是否成立,注意如果符合当前进制K,那么式子中的任何一个数都不能超过K-1;判断一个进制是否成立就是看式子中的每个数转化为该进制以后,等式是否成立;#include<bits/stdc++.h>using namespace std;typedef long long ll;string s;vector<char>v[4];char flag;b.原创 2020-08-09 22:35:45 · 287 阅读 · 0 评论 -
2020 杭电多校第五场(Multi-University Training Contest 5)
Tetrahedron大致题意:给你一个四面体(三条棱之间分别呈90度),然后给出三条棱 a , b , c 的长度的范围:随机取(1,n)之间的任意一个整数;求四面体的高h:的期望值思路:首先要找出来 a, b, c 和之间的关系;(做题的时候随便找的公式):官方题解给的证明:#include <bits/stdc++.h> using namespace std;typedef long long ll;const in...原创 2020-08-09 22:02:20 · 264 阅读 · 0 评论 -
2020 年百度之星·程序设计大赛部分题解
DrinkProblem Description一共有n个人,我们提供给他们三种饮料——可乐,雪碧,芬达每个人对这三种饮料的喜欢程度有一个顺序,一个人喝到他最喜欢的饮料可以得到 3 点快乐值,第二喜欢的饮料可以得到 2 点快乐值,第三喜欢的饮料可以得到 1 点快乐值。我们一共有nn瓶饮料,其中aa瓶是可乐,bb瓶是雪碧,cc瓶是芬达,每个人恰好分到一瓶饮料。请问适当分配这些饮料,nn个人的快乐值的和最大是多少?Input第一行一个整数test(1≤test≤100...原创 2020-08-09 09:41:14 · 4212 阅读 · 0 评论 -
Codeforces Round #639 (Div. 2) C. Hilbert's Hotel (阅读理解)
整理的算法模板:ACM算法模板总结(分类详细版)C. Hilbert's Hoteltime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputHilbert's Hotel is a very unusual hot...原创 2020-05-07 16:05:11 · 199 阅读 · 0 评论 -
AtCoder Beginner Contest 163 D - Sum of Large Numbers(规律+同余)
整理的算法模板:ACM算法模板总结(分类详细版)D - Sum of Large Numbers/Time Limit: 2 sec / Memory Limit: 1024 MBScore :400400pointsProblem StatementWe haveN+1N+1integers:1010010100,10100+110100+1, ...,10...原创 2020-04-20 07:55:18 · 397 阅读 · 0 评论 -
Codeforces Round #631 (Div. 2) B—Dreamoon Likes Permutations
整理的算法模板:ACM算法模板总结(分类详细版)题目链接:https://codeforces.ml/contest/1330题意:一个数组分成两段,长度分别为l1,l2;每段里面分别包括1~l1或者1~l2的所有数字;求有多少种l1,l2符合要求;思路:满足以下两个条件即可段的最大值maxx等于段的长度 段内没有重复元素实现方法有很多种,我刚开始写就麻烦了,用前缀和...原创 2020-04-04 11:01:23 · 179 阅读 · 0 评论 -
Codeforces Round #629 (Div. 3) D—Carousel
题目链接:https://codeforces.ml/contest/1328/problem/DA BC题就不贴了;两万多人的cf把我心态搞崩了,本来家里网速就差....打开题目,打开提交界面都要好久好久,心态崩了;qaq......题面就不上传了;见图片;D题光看题意以及样例的话很容易被误导;相同的动物可以染上不同的颜色;但是相邻的不同的动物不能染成相同的颜色;(后来不卡...原创 2020-03-27 11:29:20 · 175 阅读 · 0 评论 -
Codeforces Global Round 7 (A~D)
昨晚没报上名导致没打,不过我这菜鸡,打不打貌似都一样......A:Bad Ugly Numbers题意:让你找出来一个n位数s,对于s的每一位,s都不是其倍数,并且不含0;找到特殊组合即可;我找的2333333.......#include <bits/stdc++.h>using namespace std;int main(){ int t,n; ci...原创 2020-03-20 14:13:39 · 419 阅读 · 0 评论 -
Codeforces Round #624 (Div. 3) B,C,D;
题链:http://codeforces.com/contest/1311B WeirdSort每次指针从头开始,如果当前这个数大于下一个数,说明需要更换,这是就要判断是否有这个更换条件,然后指针更新从头开始;思想就是暴力加技巧;#include <bits/stdc++.h>using namespace std;map<int,int> mp;int a[2...原创 2020-02-25 01:09:37 · 793 阅读 · 1 评论 -
Codeforces Round #622 (Div. 2)—C—Skyscrapers (easy||hard version)
题目链接:C—SkyscrapersC1 - Skyscrapers (easy version)满足题目中要求的序列一定是一个单峰序列(包括单调),只有单峰序列才满足不存在两边大中间小的情况;所以每个点都可以构成单峰序列,只不过构成的序列值总和不一样而已,暴力枚举n个点,然后取构成单峰序列总和最大的那个点即可;数据范围1≤n≤1000,所以O(N)复杂度能过;#include <bi...原创 2020-02-24 13:48:40 · 1126 阅读 · 2 评论 -
Codeforces Round #622 (Div. 2)—B—Different Rules
B. Different Rulestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNikolay has only recently started in competitive programming, b...原创 2020-02-24 00:18:24 · 1299 阅读 · 0 评论 -
牛客小白月赛22—B-树上子链
链接:https://ac.nowcoder.com/acm/contest/4462/B来源:牛客网题目描述给定一棵树 T ,树 T 上每个点都有一个权值。定义一颗树的子链的大小为:这个子链上所有结点的权值和。请在树 T 中找出一条最大的子链并输出。输入描述:第一行输入一个 n,1≤n≤105n,1 \le n \le 10^5n,1≤n≤105。接...原创 2020-02-23 21:13:33 · 2119 阅读 · 2 评论 -
牛客小白月赛22——A-操作序列
链接:https://ac.nowcoder.com/acm/contest/4462/A来源:牛客网A-操作序列时间限制:C/C++ 5秒,其他语言10秒空间限制:C/C++ 131072K,其他语言262144K64bit IO Format: %lld题目描述给出一个长度无限的数列,初始全部为零,有三种操作:增加操作:给下标为 ttt 的数加 ccc 。特别注意,如...原创 2020-02-23 15:31:30 · 1141 阅读 · 0 评论 -
1285B Just Eat It!
链接:http://codeforces.com/contest/1285/problem/BB. Just Eat It!time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday, Yasser and Adel are at t...原创 2020-02-20 15:54:37 · 1046 阅读 · 0 评论 -
1285D Dr. Evil Underscores
链接:http://codeforces.com/contest/1285/problem/DD. Dr. Evil Underscorestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday, as a friendship ...原创 2020-02-20 15:35:00 · 668 阅读 · 0 评论 -
Codeforces Round #620 (Div. 2)—B,C;
B :Longest Palindrome如果要构造这样一个字符串,如果一个字串的反转在给的字符串集合中出现过,则说明这个字符串可以参与构造;(前提自己不是回文串);如果自己是回文串,那么可以把它构造到中间;#include <bits/stdc++.h>using namespace std;map<string ,int> mp;int main(){ i...原创 2020-02-15 23:57:46 · 1981 阅读 · 6 评论 -
2020牛客寒假算法基础集训营6—F 十字阵列
超链:https://ac.nowcoder.com/acm/contest/3007/F链接:https://ac.nowcoder.com/acm/contest/3007/F来源:牛客网题目描述小 Q 新学会了一种魔法,可以对一个 N行M列 的网格上的敌人造成伤害第 i 次使用魔法可以对网格上的一个十字形区域(即第 xi 行和第 yi 列的并)中的每个格子上的敌人造成 zi 点伤害...原创 2020-02-15 20:05:47 · 1226 阅读 · 0 评论 -
2020牛客寒假算法基础集训营5:H——Hash
链接:https://ac.nowcoder.com/acm/contest/3006/H来源:牛客网题目描述这里有一个hash函数const int LEN = 6;int mod;int Hash(char str[]){int res = 0;for (int i = 0; i < LEN; i++){res = (res * 26 + str[i] - ‘a’)...原创 2020-02-14 14:03:03 · 1550 阅读 · 0 评论 -
Codeforces Round #619 (Div. 2)
A - Three Stringsa串和b串的第i个字符一定其中有一个一定和c的第i个相同;#include <bits/stdc++.h>using namespace std;int main(){ int t; cin >>t; while(t--) { string a,b,c; cin >>a>>b>>...原创 2020-02-14 01:03:04 · 1570 阅读 · 0 评论 -
Educational Codeforces Round 82 (Rated for Div. 2)
姗姗来迟 起晚了;A. Erasing Zeroes记录第一个1出现的位置,以及最后一个1出现的位置,计算前缀和即可;wa了三发,原因是a数组我开到main()里面,但是我清零了丫,可是还是wa,原因不晓得;(并且是wa1,也就是样例都没过去,我懵了)#include <bits/stdc++.h> using namespace std;typedef long lon...原创 2020-02-13 11:14:35 · 939 阅读 · 0 评论 -
2020牛客寒假算法基础集训营4
姗姗来迟;异或那道题没想出来可惜了;官方标程:标程A:欧几里得打标找规律,题解说的斐波那契;#include <bits/stdc++.h>using namespace std;typedef long long ll;const int mod=1e9+7;struct node{ ll a,b;}bb[100];int main(){ i...原创 2020-02-11 23:58:47 · 1407 阅读 · 0 评论 -
Codeforces Round #618 (Div. 2)
c题看了半天 觉得规律是:每次找的第一个数的二进制最高位在所有数中只有它是1;明天起来补吧;原创 2020-02-10 00:11:00 · 1384 阅读 · 0 评论 -
2020牛客寒假算法基础集训营3
DP再不学估计下一场比赛就做不出来题了;比赛官方标程:标程题解..I.牛牛的汉诺塔首先汉诺塔递归到23层以后就会超时了,用递归写肯定是要记忆化搜索的,可是我不会…标程里有,费了老大劲我才找到了规律,先把前20组数据贴出来:然后呢可以总结出规律(qaq…)就是对于第二列的数,在这一列中:第一个数 == 第四个数 == (第一列的第二个数+第一列的第三个数);第三个数 == 第六...原创 2020-02-08 23:05:32 · 191 阅读 · 0 评论 -
2020牛客寒假算法基础集训营2
题目链接:2020牛客寒假算法基础集训营2官方标程题解:标程我先说一下我的感受 虽然我菜 但是还是想吐槽G题的概率取模,真恶心;D:数三角我的做法是用向量做,暴力枚举任意的三个点,然后算出以每个点为顶点的角的两条边的向量乘积,看是否小于0,这里需要注意判断两个向量是否共线,也就是判断三个点是否共线:#include <bits/stdc++.h>using name...原创 2020-02-06 23:35:03 · 1712 阅读 · 2 评论 -
Codeforces Round #616 (Div. 2)
A. Even But Not Eventime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet’s define a number ebne (even but not even) if and only if its sum of d...原创 2020-02-03 13:46:59 · 357 阅读 · 0 评论 -
Nick and Array CodeForces - 1180B
Nick had received an awesome array of integers a=[a1,a2,…,an] as a gift for his 5 birthday from his mother. He was already going to explore its various properties but after unpacking he was disappoint...原创 2019-12-01 11:05:24 · 203 阅读 · 0 评论 -
AB Substrings AtCoder - 5039
Problem StatementSnuke has N strings. The i-th string is si.Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of AB...原创 2019-11-21 21:28:58 · 148 阅读 · 0 评论 -
Kleene Inversion AtCoder - 5165
Problem StatementWe have a sequence of N integers A=A0,A1,…,~AN−1.Let B be a sequence of K×N integers obtained by concatenating K copies of A. For example, if A=1,3,2 and K=2, B=1,3,2,1,3,~2.Find t...原创 2019-11-21 21:21:25 · 162 阅读 · 0 评论 -
Powerful Discount Tickets AtCoder - 4864
Problem StatementTakahashi is going to buy N items one by one.The price of the i-th item he buys is Ai yen (the currency of Japan).He has M discount tickets, and he can use any number of them when ...原创 2019-11-21 21:08:43 · 218 阅读 · 0 评论 -
Monsters Battle Royale AtCoder - 4297
Problem StatementThere are N monsters, numbered 1,2,…,N.Initially, the health of Monster i is Ai.Below, a monster with at least 1 health is called alive.Until there is only one alive monster, the ...原创 2019-11-21 20:48:07 · 269 阅读 · 0 评论 -
Counting of Trees AtCoder - 5633
Problem StatementGiven is an integer sequence D1,…,DN of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:For every intege...原创 2019-11-21 20:43:06 · 561 阅读 · 0 评论