![](https://img-blog.csdnimg.cn/20190927151026427.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
题解
文章平均质量分 80
记录一些ACM题、力扣题的题解,cf的题解
指间理想
这里没有简介~
展开
-
蓝桥杯国赛五一训练赛(1)
蓝桥杯国赛五一训练赛(1)(链接)问题 A: 费解的开关你玩过“拉灯”游戏吗?25盏灯排成一个5x5的方形。每一个灯都有一个开关,游戏者可以改变它的状态。每一步,游戏者可以改变某一个灯的状态。游戏者改变一个灯的状态会产生连锁反应:和这个灯上下左右相邻的灯也要相应地改变其状态。我们用数字“1”表示一盏开着的灯,用数字“0”表示关着的灯。下面这种状态1011101101101111000011011在改变了最左上角的灯的状态后将变成:0111111101101111000011011原创 2022-05-01 11:25:34 · 419 阅读 · 2 评论 -
2022年“5校联盟”蓝桥杯软件大赛训练赛8(2022.01.27)
题目地址:http://182.92.175.181/contest.php?cid=2353问题 A: 电路维修题意具体是通过旋转方块找到一条联通左上角和右下角的线路。一个方块有四个顶点,如果线路是’\'可以在左上角到右下角的点建一条权值为0的边,否则在左下角到右上角的点建一条权值为1的边,另一种情况同理。此时可以将问题转化成:带权图中求一条左上角到右下角的最短路径,朴素的方法如可能会超时,需要一些优化。可以使用双端队列,将不需要旋转就能达到的点从队头加入,反之加入队尾可以加速搜索的过程。也可以使用双原创 2022-01-28 16:10:00 · 870 阅读 · 0 评论 -
二叉堆及其基本操作
二叉堆基本操作及其实现:用数组实现,1为根插入操作:在数组的末尾插入数据,并从该节点开始往根节点调整直至满足大/小根堆的性质void insert(int val,int pos){ //插入操作heap[pos]=val;up_adjust(pos);}删除操作:1.将堆顶元素删除:交换heap[1],heap[n](最后一个元素),然后移除最后一个元素(可以是将n减一),最后向下调整堆。void pop(){heap[1]=heap[n- -];down_adjust(1);}原创 2021-09-05 16:35:36 · 164 阅读 · 0 评论 -
ICPC训练联盟2021寒假冬令营(5)(部分题解):
ICPC训练联盟2021寒假冬令营(5)(部分题解):A - BrainmanRaymond Babbitt drives his brother Charlie mad. Recently Raymond counted 246 toothpicks spilled all over the floor in an instant just by glancing at them. And he can even count Poker cards. Charlie would love to be原创 2021-02-01 21:45:47 · 562 阅读 · 0 评论 -
逆波兰表达式
中缀表达式转换成后缀表达式,利用后缀表达式计算算式的值中缀表达式,即我们日常生活中所熟知的表达式,后缀表达式…自行百度…例如:4+2*5-7/11,将上述中缀表达式转换成后缀表达式后为4 2 5 * + 7 11 / -,中缀表达式转换成后缀表达式的步骤为(Ps:中缀表达式转换为后缀表达式并不唯一):用于存放后缀表达式的容器自备~~,转换的过程中需要栈遍历中缀表达式,遇到数字,直接存入后缀表达式中,遇到运算符:若为 ’ ( '(优先级最高),直接入栈,若为其余运算符(+ - * /),如果栈为空,直原创 2021-02-10 19:08:08 · 117 阅读 · 2 评论 -
菜鸡成长之路之STL
菜鸡成长之路之STLA - 圆桌问题圆桌上围坐着2n个人。其中n个人是好人,另外n个人是坏人。如果从第一个人开始数数,数到第m个人,则立即处死该人;然后从被处死的人之后开始数数,再将数到的第m个人处死……依此方法不断处死围坐在圆桌上的人。试问预先应如何安排这些好人与坏人的座位,能使得在处死n个人之后,圆桌上围坐的剩余的n个人全是好人。Input多组数据,每组数据输入:好人和坏人的人数n(<=32767)、步长m(<=32767);Output对于每一组数据,输出2n个大写字母,‘G’原创 2021-02-11 16:41:43 · 146 阅读 · 1 评论 -
ICPC训练联盟2021寒假冬令营(3)(部分题解):
ICPC训练联盟2021寒假冬令营(3)(部分题解):C - Simple divisionInteger division between a dividend n and a divisor d yields a quotient q and a remainder r. q is the integer which maximizes q ∗ dsuch that q ∗ d ≤ n and r = n − q ∗ d.For any set of integers there is an原创 2021-02-01 21:42:34 · 551 阅读 · 0 评论 -
数列和
题目描述给定一个长度为N的数列A,然后进行若干次询问,每次给定一个整数T,求出最大的k,满足A1+A2+…+Ak≤T输入第一行为正整数N,N小于1000000第二行为N个正整数,组成数列A,每个正整数的小于等于1000000接下来包括多行,每行包括一个正整数T输出对给定正整数数列A和正整数T,输出满足条件的k,然后换行样例输入 Copy51 2 3 5 4671015样例输出 Copy3335老实人就该用老实人的办法[doge]思路:定义结构体,成员有index、r原创 2021-01-21 21:33:24 · 425 阅读 · 0 评论 -
ICPC训练联盟2021寒假冬令营(1)(部分题解):
**ICPC训练联盟2021寒假冬令营(1)(部分题解):B - Pig-Latin:You have decided that PGP encryptation is not strong enough for your email. You have decided to supplement it by first converting your clear text letter into Pig Latin before encrypting it with PGP.Input and O原创 2021-02-01 21:13:56 · 460 阅读 · 0 评论 -
ICPC训练联盟2021寒假冬令营(7)部分题解
ICPC训练联盟2021寒假冬令营(7)部分题解:A - DoublesAs part of an arithmetic competency program, your students will be given randomly generated lists of from 2 to 15 unique positive integers and asked to determine how many items in each list are twice some other item i原创 2021-02-10 18:03:28 · 386 阅读 · 0 评论 -
ICPC训练联盟2021寒假冬令营(2)(部分题解)
ICPC训练联盟2021寒假冬令营(2)(部分题解)B - Diplomatic LicenseIn an effort to minimize the expenses for foreign affairs the countries of the world have argued as follows. It is not enough that each country maintains diplomatic relations with at most one other country原创 2021-02-01 21:36:23 · 1211 阅读 · 0 评论 -
ICPC训练联盟2021寒假冬令营(6)部分题解:
**ICPC训练联盟2021寒假冬令营(6)部分题解**写好忘发了~~A - The Blocks ProblemMany areas of Computer Science use simple, abstract domains for both analytical and empirical studies. For example, an early AI study of planning and robotics (STRIPS) used a block world in whi原创 2021-02-10 18:00:54 · 436 阅读 · 0 评论 -
菜鸡成长之路之搜索
居然发现这篇写好的题解依然躺在我桌面上…明明记得发过Talk is cheap, Show me the code,上题目代码(以下都是基础练习题,并不包括用到像启发式搜索这种高端算法的题):A - Red and BlackThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a原创 2021-07-25 15:00:02 · 185 阅读 · 1 评论 -
Homogeneous Squares
**Homogeneous Squares**Assume you have a square of size n that is divided into n × n positions just as a checkerboard. Two positions (x1, y1) and (x2, y2), where 1 ≤ x1, y1, x2, y2 ≤ n, are called “independent” if they occupy different r...原创 2021-01-21 18:32:26 · 221 阅读 · 0 评论