![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++
文章平均质量分 55
旧林墨烟
惠州学院大四学生,热爱算法竞赛,获得蓝桥杯、天梯赛、ccpc、icpc等多项奖项,熟悉c++、java语言,目前处于求职状态
展开
-
2024蓝桥杯省赛出成绩时间
看看各年蓝桥杯出成绩的时间吧:2018年:4.1-4.9,8天2019年:3.24-3.31,7天2020年:10.17-10.26,9天2021年:4.18-4.28,10天2022年:4-9,至今4.25,16天了还没成绩太痛苦了.jpg原创 2022-04-25 20:48:15 · 22776 阅读 · 23 评论 -
c++ 万能头文件
include<bits/stdc++.h>妈妈再也不用担心孩子忘记头文件啦!原创 2022-03-19 10:56:44 · 2304 阅读 · 4 评论 -
c++ to_string()和stoi() 等 字符串/数字 转换函数
to_string()函数作用: 将基本类型的值转换为字符串基本类型包括int、long long、char等等使用的时候注意超限问题就好了,特殊地,char类型的转换是转换成它的ASCII值,而不是字符#include<iostream>using namespace std;int main(){ string s; int a=111111; long long b=222222; char c='a'; s=to_string(a); cout<<s&原创 2022-01-31 21:02:26 · 1570 阅读 · 0 评论 -
dev使用c++11教程
dev无法使用c++11新特新dev无法使用unordered_map,unordered_set,foreach循环原创 2022-01-23 16:50:52 · 4857 阅读 · 1 评论 -
U - Tallest Cow (差分)
FJ’s N (1 ≤ N ≤ 10,000) cows conveniently indexed 1…N are standing in a line. Each cow has a positive integer height (which is a bit of secret). You are told only the height H (1 ≤ H ≤ 1,000,000) of the tallest cow along with the index I of that cow.FJ ha原创 2021-10-06 20:34:55 · 195 阅读 · 0 评论 -
T - Covered Points Count (差分)
You are given n segments on a coordinate line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can intersect with each other, be nested in each other or even coincide.Your task is the following: for原创 2021-10-06 19:19:22 · 120 阅读 · 0 评论 -
S - Karen and Coffee(前缀和)
To stay woke and attentive during classes, Karen needs some coffee!Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, including the univer原创 2021-10-06 16:55:35 · 216 阅读 · 0 评论 -
R - Color the ball (前缀和)
N个气球排成一排,从左到右依次编号为1,2,3…N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗?Input每个测试实例第一行为一个整数N,(N <= 100000).接下来的N行,每行包括2个整数a b(1 <= a <= b <= N)。当N = 0,输入结束。Output每个测试实例输出一原创 2021-10-06 14:18:53 · 109 阅读 · 2 评论 -
Q - Conturbatio (前缀和)
There are many rook on a chessboard, a rook can attack the row and column it belongs, including its own place.There are also many queries, each query gives a rectangle on the chess board, and asks whether every grid in the rectangle will be attacked by an原创 2021-10-06 13:11:24 · 164 阅读 · 0 评论 -
P - CS Course (前缀和+后缀和)
Little A has come to college and majored in Computer and Science.Today he has learned bit-operations in Algorithm Lessons, and he got a problem as homework.Here is the problem:You are giving n non-negative integers a1,a2,⋯,an, and some queries.A query原创 2021-10-05 21:36:57 · 101 阅读 · 0 评论 -
O - Bound Found (前缀和+滑动窗口)
Signals of most probably extra-terrestrial origin have been received and digitalized by The Aeronautic and Space Administration (that must be going through a defiant phase: “But I want to use feet, not meters!”). Each signal seems to come in two parts: a s原创 2021-10-05 20:27:55 · 171 阅读 · 0 评论 -
N - Maximum Subrectangle (前缀和)
You are given two arrays a and b of positive integers, with length n and m respectively.Let c be an n×m matrix, where ci,j=ai⋅bj.You need to find a subrectangle of the matrix c such that the sum of its elements is at most x, and its area (the total numbe原创 2021-10-05 20:12:04 · 152 阅读 · 0 评论 -
M - Buy Sticks (贪心)
Imyourgod need 3 kinds of sticks which have different sizes: 20cm, 28cm and 32cm. However the shop only sell 75-centimeter-long sticks. So he have to cut off the long stick. How many sticks he must buy at least.InputThe first line of input contains a num原创 2021-10-04 17:15:02 · 83 阅读 · 0 评论 -
L - Fishing Master (贪心)
Heard that eom is a fishing MASTER, you want to acknowledge him as your mentor. As everybody knows, if you want to be a MASTER’s apprentice, you should pass the trial. So when you find fishing MASTER eom, the trial is as follow:There are n fish in the poo原创 2021-10-04 12:42:44 · 94 阅读 · 0 评论 -
K - Doing Homework again (贪心)
Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands in the homework after the deadline, the teacher will reduce his score of the fin原创 2021-10-03 21:31:40 · 86 阅读 · 0 评论 -
I - Cleaning Shifts (贪心)
Farmer John is assigning some of his N (1 <= N <= 25,000) cows to do some cleaning chores around the barn. He always wants to have one cow working on cleaning things up and has divided the day into T shifts (1 <= T <= 1,000,000), the first bein原创 2021-10-03 17:48:56 · 95 阅读 · 0 评论 -
H - Packets (贪心)
A factory produces products packed in square packets of the same height h and of the sizes 11, 22, 33, 44, 55, 66. These products are always delivered to customers in the square parcels of the same height h as the products have and of the size 6*6. Because原创 2021-10-03 17:37:57 · 104 阅读 · 0 评论 -
G - Best Cow Line (贪心)
FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his cows in a line and herds them past the judges.The contest organizers adopted a new registration scheme this year: simpl原创 2021-10-02 00:38:06 · 114 阅读 · 0 评论 -
F - Bin Packing (贪心)
A set of n 1-dimensional items have to be packed in identical bins. All bins have exactly the same length l and each item i has length li<=l . We look for a minimal number of bins q such thateach bin contains at most 2 items,each item is packed in one原创 2021-10-01 23:45:23 · 124 阅读 · 0 评论 -
C - The Frog‘s Games (贪心)
The annual Games in frogs’ kingdom started again. The most famous game is the Ironfrog Triathlon. One test in the Ironfrog Triathlon is jumping. This project requires the frog athletes to jump over the river. The width of the river is L (1<= L <= 100原创 2021-10-01 21:59:01 · 92 阅读 · 0 评论 -
B - Drying (二分法)
It is very hard to wash and especially to dry clothes in winter. But Jane is a very smart girl. She is not afraid of this boring process. Jane has decided to use a radiator to make drying faster. But the radiator is small, so it can hold only one thing at原创 2021-10-01 21:42:47 · 191 阅读 · 0 评论 -
A - Monthly Expense
Farmer John is an astounding accounting wizard and has realized he might run out of money to run the farm. He has already calculated and recorded the exact amount of money (1 ≤ moneyi ≤ 10,000) that he will need to spend each day over the next N (1 ≤ N ≤ 1原创 2021-10-01 21:25:42 · 96 阅读 · 0 评论 -
E - Best Cow Fences (二分法)
Farmer John’s farm consists of a long row of N (1 <= N <= 100,000)fields. Each field contains a certain number of cows, 1 <= ncows <= 2000.FJ wants to build a fence around a contiguous group of these fields in order to maximize the average num原创 2021-10-01 21:02:50 · 169 阅读 · 0 评论 -
D-Showstopper (二分搜索)
Data-mining huge data sets can be a painful and long lasting process if we are not aware of tiny patterns existing within those data sets.One reputable company has recently discovered a tiny bug in their hardware video processing solution and they are try原创 2021-10-01 18:56:25 · 91 阅读 · 0 评论 -
一篇文章吃透背包问题!(细致引入+解题模板+例题分析+代码呈现)
背包问题背包问题解题模板典型题目1049. 最后一块石头的重量 II322. 零钱兑换416. 分割等和子集494. 目标和279. 完全平方数377. 组合总和 Ⅳ518. 零钱兑换 II1155. 掷骰子的N种方法背包问题背包问题:背包问题是动态规划非常重要的一类问题,它有很多变种,但题目千变万化都离不开我根据力扣上背包问题的题解总结的解题模板。负责任地说,吃透这一篇文章,力扣上所有背包问题拿过来就可以秒杀!背包定义:那么什么样的问题可以被称作为背包问题?换言之,我们拿到题目如何透过题目的不同转载 2021-08-27 23:19:31 · 2164 阅读 · 2 评论 -
c++算法笔记(更新中)
c++ 算法笔记算法排序算法排序算法基本分为八种冒泡排序插入排序堆排序选择排序快速排序归并排序基数排序希尔排序当然,并不要求完全掌握全部的排序方法。虽然如此,理解其中的实现原理是很有必要的。这为我们遇到相似问题是提供思路遇到排序问题时可以使用头文件algorthm中的sort()和stable_sort()函数来实现排序sort()的实现用的是快速排序,并不稳定。需要稳定排序时可以用stable_sort()来实现,实现是归并排序。两个排序的复杂度都是O(nlogn),但原创 2021-08-12 05:05:41 · 414 阅读 · 1 评论 -
完全平方数(妙解)
时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 131072K,其他语言262144K64bit IO Format: %lld题目描述多次查询[l,r]范围内的完全平方数个数定义整数x为完全平方数当且仅当可以找到整数y使得y*y=x输入描述:第一行一个数n表示查询次数之后n行每行两个数l,r输出描述:对于每个查询,输出一个数表示答案示例1输入51 31 42 44 41 1000000000输出121131622备注:n <= 1原创 2021-06-13 14:50:52 · 1128 阅读 · 0 评论 -
c++ for循环的新写法
for循环遍历一个数组、string类、vector类等老写法:#include<iostream>#include<string>#include<vector>using namespace std;int main(){ int a[10]={1,2,3,4,5,6,7,8,9}; string b("abcdefg"); vector<int> c(5); c[1]=1,c[2]=2,c[3]=3,c[4]=4; int i;原创 2021-06-09 00:43:13 · 2496 阅读 · 1 评论 -
c++函数模板
用法:template <class 类型参数1,class 类型参数2,...>//用class和typename都可以返回值类型 模板名(形参表){ 函数体}作用:解决同一函数因类型名不同须写多个相似函数的问题举例:首先我们按普通思路写一个Max()函数,要求返回两个数中的较大者,为了函数的通用性我们需要重载多个函数代码如下:#include<string>using namespace std;int Max(int a,int b){ retu原创 2021-06-08 23:59:03 · 115 阅读 · 1 评论 -
c++ string类所占字节数
string类仅有一个数据成员,char*指针,故string类的大小和指针相似,在64位的运行环境下占8个字节,在32位的运行环境下占4个字节代码:#include<iostream>#include<string>using namespace std;int main(){ string a="12345678910"; cout<<sizeof(string)<<endl; cout<<sizeof(a)<<e原创 2021-06-08 23:32:21 · 6067 阅读 · 6 评论 -
构造完全图(最小生成树,Kruskal算法)
时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述对于完全图G,若有且仅有一棵最小生成树为T,则称完全图G是树T扩展出的。给你一棵树T,找出T能扩展出的边权和最小的完全图G。输入描述:第一行N表示树T的点数;接下来N-1行三个整数S i ,T i,D i;描述一条边(S i ,T i )权值为D i ; 保证输入数据构成一棵树。输出描述:输出仅一个数,表示最小的完全图GGG的边.原创 2021-06-04 21:45:49 · 1682 阅读 · 1 评论 -
新的开始(最小生成数,Dijkstra算法)
时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536K 64bit IO Format:%lld题目描述发展采矿业当然首先得有矿井,小FF花了上次探险获得的千分之一的财富请人在岛上挖了n口矿井,但他似乎忘记考虑的矿井供电问题……为了保证电力的供应,小FF想到了两种办法: 在这一口矿井上建立一个发电站,费用为v(发电站的输出功率可以供给任意多个矿井)。将这口矿井与另外的已经有电力供应的矿井之间建立电网,费用为p。小FF希望身为「NewBe_One」.原创 2021-06-04 18:10:01 · 181 阅读 · 1 评论 -
北极通讯网络(最小生成数,Kruskal算法)
时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述北极的某区域共有n座村庄,每座村庄的坐标用一对整数(x,y)表示。为了加强联系,决定在村庄之间建立通讯网络。通讯工具可以是无线电收发机,也可以是卫星设备。所有的村庄都可以拥有一部无线电收发机,且所有的无线电收发机型号相同。但卫星设备数量有限,只能给一部分村庄配备卫星设备。不同型号的无线电收发机有一个不同的参数d,两座村庄之间的距离如果不超过d就可以用该型原创 2021-06-04 00:10:50 · 243 阅读 · 4 评论 -
黑暗城堡(dijkstra算法)
时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述你知道黑暗城堡有N个房间,M条可以制造的双向通道,以及每条通道的长度。城堡是树形的并且满足下面的条件:设D i为如果所有的通道都被修建,第i号房间与第1号房间的最短路径长度;而Si为实际修建的树形城堡中第i号房间与第1号房间的路径长度;要求对于所有整数i(1≤i≤N),有Si=Di成立。你想知道有多少种不同的城堡修建方案。当然,你只需要输出答案对原创 2021-06-03 01:04:29 · 980 阅读 · 9 评论 -
进阶实验6-3.5 关键活动 (拓扑排序)
假定一个工程项目由一组子任务构成,子任务之间有的可以并行执行,有的必须在完成了其它一些子任务后才能执行。“任务调度”包括一组子任务、以及每个子任务可以执行所依赖的子任务集。比如完成一个专业的所有课程学习和毕业设计可以看成一个本科生要完成的一项工程,各门课程可以看成是子任务。有些课程可以同时开设,比如英语和C程序设计,它们没有必须先修哪门的约束;有些课程则不可以同时开设,因为它们有先后的依赖关系,比如C程序设计和数据结构两门课,必须先学习前者。但是需要注意的是,对一组子任务,并不是任意的任务调度都是一个可原创 2021-05-04 13:38:50 · 785 阅读 · 4 评论 -
基础实验6-2.2 汉密尔顿回路 (模拟)
著名的“汉密尔顿(Hamilton)回路问题”是要找一个能遍历图中所有顶点的简单回路(即每个顶点只访问 1 次)。本题就要求你判断任一给定的回路是否汉密尔顿回路。输入格式:首先第一行给出两个正整数:无向图中顶点数 N(2<N≤200)和边数 M。随后 M 行,每行给出一条边的两个端点,格式为“顶点1 顶点2”,其中顶点从 1 到N 编号。再下一行给出一个正整数 K,是待检验的回路的条数。随后 K 行,每行给出一条待检回路,格式为:n V1 V2 ⋯ Vn其中 n 是回路中的顶点数,原创 2021-05-03 12:37:56 · 341 阅读 · 2 评论 -
案例3-1.9 银行业务队列简单模拟 (模拟)
设某银行有A、B两个业务窗口,且处理业务的速度不一样,其中A窗口处理速度是B窗口的2倍 —— 即当A窗口每处理完2个顾客时,B窗口处理完1个顾客。给定到达银行的顾客序列,请按业务完成的顺序输出顾客序列。假定不考虑顾客先后到达的时间间隔,并且当不同窗口同时处理完2个顾客时,A窗口顾客优先输出。输入格式:输入为一行正整数,其中第1个数字N(≤1000)为顾客总数,后面跟着N位顾客的编号。编号为奇数的顾客需要到A窗口办理业务,为偶数的顾客则去B窗口。数字间以空格分隔。输出格式:按业务处理完成的顺序输出顾客原创 2021-05-03 05:10:43 · 189 阅读 · 2 评论 -
基础实验8-1.2 直捣黄龙 (Dijkstra算法)
本题是一部战争大片 —— 你需要从己方大本营出发,一路攻城略地杀到敌方大本营。首先时间就是生命,所以你必须选择合适的路径,以最快的速度占领敌方大本营。当这样的路径不唯一时,要求选择可以沿途解放最多城镇的路径。若这样的路径也不唯一,则选择可以有效杀伤最多敌军的路径。输入格式:输入第一行给出2个正整数N(2 ≤ N ≤ 200,城镇总数)和K(城镇间道路条数),以及己方大本营和敌方大本营的代号。随后N-1行,每行给出除了己方大本营外的一个城镇的代号和驻守的敌军数量,其间以空格分隔。再后面有K行,每行按格式城原创 2021-05-03 01:55:06 · 1007 阅读 · 6 评论 -
基础实验7-2.1 魔法优惠券 (贪心)
在火星上有个魔法商店,提供魔法优惠券。每个优惠劵上印有一个整数面值K,表示若你在购买某商品时使用这张优惠劵,可以得到K倍该商品价值的回报!该商店还免费赠送一些有价值的商品,但是如果你在领取免费赠品的时候使用面值为正的优惠劵,则必须倒贴给商店K倍该商品价值的金额…… 但是不要紧,还有面值为负的优惠劵可以用!(真是神奇的火星)例如,给定一组优惠劵,面值分别为1、2、4、-1;对应一组商品,价值为火星币M7、6、-2、-3,其中负的价值表示该商品是免费赠品。我们可以将优惠劵3用在商品1上,得到M28的回报;优惠原创 2021-05-02 17:36:06 · 678 阅读 · 1 评论 -
基础实验6-2.3 拯救007 (bfs)
在老电影“007之生死关头”(Live and Let Die)中有一个情节,007被毒贩抓到一个鳄鱼池中心的小岛上,他用了一种极为大胆的方法逃脱 —— 直接踩着池子里一系列鳄鱼的大脑袋跳上岸去!(据说当年替身演员被最后一条鳄鱼咬住了脚,幸好穿的是特别加厚的靴子才逃过一劫。)设鳄鱼池是长宽为100米的方形,中心坐标为 (0, 0),且东北角坐标为 (50, 50)。池心岛是以 (0, 0) 为圆心、直径15米的圆。给定池中分布的鳄鱼的坐标、以及007一次能跳跃的最大距离,你需要告诉他是否有可能逃出生天。原创 2021-05-01 23:14:05 · 411 阅读 · 1 评论