自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 折半搜索笔记

01爆搜的时间复杂度通常为O2n,只能应付N为20左右的题目,但是折半搜索可以应付N为3040的题目。

2025-02-26 15:25:02 1059

原创 PAT--1035 插入与归并

是迭代算法,逐一获得输入数据,逐步产生有序的输出序列。每步迭代中,算法从输入序列中取出一元素,将之插入有序序列中正确的位置。行中输出用该排序算法再迭代一轮的结果序列。题目保证每组测试的结果是唯一的。数字间以空格分隔,且行首尾不得有多余空格。最后一行给出由某排序算法产生的中间序列。这里假设排序的目标序列是升序。现给定原始序列和由某排序算法产生的中间序列,请你判断该算法究竟是哪种排序算法?个元素的有序子序列,然后每次迭代归并两个相邻的有序子序列,直到最后只剩下。随后一行给出原始序列的。输入在第一行给出正整数。

2024-12-11 16:51:00 1139

原创 二维立柱图|积水类问题

我们将这一段截面上的土地分割成单位宽度的窄条,测量出每个窄条的高度。假设有无穷多的水量从天而降,请你计算一下,这段路面上会形成多少个水坑?注意:即使两个相邻的水坑有相同高度的水平面,只要之间有障碍物相隔,就算是两个水坑。输出分两行,第一行输出水坑的个数,第二行输出所有水坑中最大的深度,以毫米为单位。注意:即使两个相邻的水坑有相同高度的水平面,只要之间有窄条相隔,就算是两个水坑。个非负整数,为路面横截面总左到右的单位宽度窄条的高度,以毫米为单位,不超过。,那么就说明了他们是属于同一水坑,否则第。

2024-12-10 19:31:42 710

原创 [USACO20OPEN] Cereal S (DFS)

Farmer John 的奶牛们的早餐最爱当然是麦片了!事实上,奶牛们的胃口是如此之大,每头奶牛一顿饭可以吃掉整整一箱麦片。

2024-12-04 19:16:01 1090

原创 PTA-L2-004 这是二叉搜索树吗?

一棵二叉搜索树可被递归地定义为具有下列性质的二叉树:对于任一结点,其左子树中所有结点的键值小于该结点的键值;其右子树中所有结点的键值大于等于该结点的键值;其左右子树都是二叉搜索树。所谓二叉搜索树的“镜像”,即将所有结点的左右子树对换位置后所得到的树。

2024-04-17 14:31:50 751 1

原创 2021年PAT--春

In computer science, amax-heapis a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is greater than or equal to the key of C. A common implementation of a heap is the binary

2024-03-08 17:27:38 762

原创 2020年PAT--冬

Achemical equationis the symbolic representation of a chemical reaction in the form of symbols and formulae, wherein the reactant entities are given on the left-hand side and the product entities on the right-hand side. For example,CH4​+2O2​=CO2​+2H2​O

2024-03-04 15:29:48 909

原创 2020年PAT--秋

Professional Ability Test (PAT) consists of several series of subject tests. Each test is divided into several levels. Level A is aprerequisite (前置要求)of Level B if one must pass Level A with a score no less thanSin order to be qualified to take Level B

2024-03-02 16:11:32 970

原创 2023年PAT--秋

You are supposed to implement an auto taxi management system: for each customer who is ordering a service, send a command to an auto taxi that can take the shortest time to reach the customer. The rules are:One can only get a taxi and set one's destinati

2023-11-27 18:03:58 938 4

原创 PTA--1087 All Roads Lead to Rome(最短路计数+输出路径)

Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness.Input Specification:Each input file contains one test case. For each case, the fir

2023-10-28 17:14:52 283

原创 PTA--1030 Travel Plan(最短路+记录路径)

给定n个点,m条边,起点x和终点y,每条边有四个参数,分别表示两端和距离和途径花费,问你x到y最短路径是哪条,如果不止一条,那么就选择花费少的,要求你输出路径和最短路径和最短花费。:最短路跑一边即可,记录一个路径path,跑最短路时记录下这个点的前置点是谁,最后从终点返回起点,最后反转一下就是路径。

2023-10-27 16:34:52 213

原创 PTA--1014 Waiting in Line(模拟队列)

Suppose a bank hasNwindows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the customers to wait in line are:The space inside the yellow line in front of each window is enoug

2023-10-27 15:21:59 172

原创 Codeforces Round 900 (Div. 3)--E. Iva & Pav(前缀和+二分)

​Iva and Pav are a famous Serbian competitive programming couple. In Serbia, they call Pav "papuca" and that's why he will make all of Iva's wishes come true.Iva gave Pav an arrayaofnelements.Let's definef(l,r)=al&al+1&…&ar (here&&denotes t

2023-09-29 12:40:32 867

原创 The 2023 ICPC Asia Regionals Online Contest (2) --E Another Bus Route Problem(BFS)

Pik's village comprises ofnresidential buildings (labeled from1ton) connected byn−1bidirectional roads. The village forms a tree structure, where each building is interpreted as a tree vertex, and each road is interpreted as a tree edge. Within the

2023-09-26 18:47:52 219

原创 P1195 口袋的天空(联通块个数+最小生成树)

小杉坐在教室里,透过口袋一样的窗户看口袋一样的天空。有很多云飘在那里,看起来很漂亮,小杉想摘下那样美的几朵云,做成棉花糖。给你云朵的个数N,再给你M个关系,表示哪些云朵可以连在一起。现在小杉要把所有云朵连成K个棉花糖,一个棉花糖最少要用掉一朵云,小杉想知道他怎么连,花费的代价最小。

2023-09-25 11:47:52 197

原创 Codeforces Round 895 (Div. 3) (A~G)

Given an array a of n positive integers. You need to perform the following operation exactly once:Choose 2 integers l and r (1≤l≤r≤n) and replace the subarray a[l…r] with the single element: the product of all elements in the subarray (al⋅…⋅ar).

2023-09-09 18:43:30 574 1

原创 CF Round 481 (Div. 3)--E. Bus Video System(二分)

The busses in Berland are equipped with a video surveillance system. The system records information about changes in the number of passengers in a bus after stops.Ifxis the number of passengers in a bus just before the current bus stop andyis the num

2023-09-07 17:03:09 162

原创 CF Round 481 (Div. 3)--D. Almost Arithmetic Progression(思维)

Polycarp likes arithmetic progressions. A sequence[a1,a2,…,an] is called an arithmetic progression if for eachi(1≤i

2023-09-07 14:42:43 157

原创 CF Round 479 (Div. 3)--D. Divide by three, multiply by two(离散化+拓扑排序)

Polycarp likes to play with numbers. He takes some integer numberx, writes it down on the board, and then performs with itn−1 operations of the two kinds:divide the numberxby3(xmust be divisible by3);multiply the numberxby2.After each operat

2023-09-06 19:37:26 151

原创 CF Round 479 (Div. 3)--E. Cyclic Components(DFS求无向图中独立环的个数)

You are given an undirected graph consisting ofnvertices andmedges. Your task is to find the number of connected components which are cycles.Here are some definitions of graph theory.An undirected graph consists of two sets: set of nodes (called ve

2023-09-06 19:10:26 704

原创 AtCoder Beginner Contest 045--D - Snuke‘s Coloring(思维)

We have a grid withHrows andWcolumns. At first, all cells were painted white.Snuke paintedNof these cells. Thei-th ( 1≤i≤N) cell he painted is the cell at the ai​-th row andbi​-th column.Compute the following:For each integerj( 0≤j≤9), ho

2023-09-05 20:50:17 134

原创 AtCoder Beginner Contest 042--D - Iroha and a Grid(排列组合)

We have a large square grid withHrows andWcolumns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell.However, she cannot enter the cells in the intersection o

2023-09-05 13:39:27 252

原创 POJ--3276--Face The Right Way(暴力枚举)

Farmer John has arranged hisN(1 ≤N≤ 5,000) cows in a row and many of them are facing forward, like good cows. Some of them are facing backward, though, and he needs them all to face forward to make his life perfect.

2023-09-04 19:23:35 88

原创 Codeforces Round 893 (Div. 2)--B. The Walkway(前后缀和)

There arenbenches near the Main Walkway in Summer Infomatics School. These benches are numbered by integers from1tonin order they follow. Also there aremcookie sellers near the Walkway. Thei-th (1≤i≤m) cookie sellers is located near thesi-th benc

2023-08-16 16:37:13 341

原创 2023“钉耙编程”中国大学生算法设计超级联赛4--Simple Set Problem(双指针)

Givenknon empty multiple sets, each multiple set only contains integers with absolute values not exceeding10^9.It is required to select exactly one number from each multiple set to form an array(a1,a2,…,ak)with a length ofk.Assumingd=max(a1,a2,…

2023-07-27 21:01:11 262

原创 PTA--1002 Fire Net(DFS)

Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall.A blockhouse is a small castle that has four openings through which to shoot. The four op

2023-07-27 19:23:21 228

原创 2023牛客暑期多校训练营3--J Fine Logic(拓扑排序)

We consider a set G consisting of nnn entities and the relations on G. For simplicity, these n entities are labeled from 1to n.The ranking Ron Gis defined as an nnn-order permutation R=r1,r2,…rn(1≤ri​≤n).The winning relation on Gis defined as an or

2023-07-24 18:12:54 80

原创 2023牛客暑期多校训练营1--K Subdivision(最短路树)

You are given a graph with n vertices and m undirected edges of length 1. You can do the following operation on the graph for arbitrary times:Choose an edge (u,v) and replace it by two edges, (u,w) and (w,v), where w is a newly inserted vertex. Both of

2023-07-22 18:57:21 173

原创 2023“钉耙编程”中国大学生算法设计超级联赛2--Binary Number

You are given a binary numbers1∼n(s1is the highest bit.snis the lowest bit.). You need to do an operationexactlyktimes: select an interval[l,r](1≤l≤r≤n)arbitrarily and flipsl,sl+1,...,sr, in other word, for alli∈[l,r],sibecomes1ifsiis0,

2023-07-22 17:18:34 139

原创 2023牛客暑期多校训练营2-K--Box(线性DP)

Now, the Traveler has nboxes in their possession, some of which have lids that can be shifted left or right by at most one step. If the i-th box is covered with a lid, you gain ai score.(Covering it with multiple lids still gets onlyaiscore.) Determine

2023-07-22 16:49:26 234

原创 洛谷P2986--Great Cow Gathering G(换根DP)

在选择集会的地点的时候,Bessie 希望最大化方便的程度(也就是最小化不方便程度)。比如选择第 X 个农场作为集会地点,它的不方便程度是其它牛棚中每只奶牛去参加集会所走的路程之和(比如,农场 ii 到达农场 X 的距离是 20,那么总路程就是 Ci​×20)。每个奶牛居住在 N 个农场中的一个,这些农场由 N-1 条道路连接,并且从任意一个农场都能够到达另外一个农场。集会可以在 N 个农场中的任意一个举行。第 N+2 行到 2N 行:第 i+N+1 行为 3 个整数:Ai​,Bi​ 和 Li​。

2023-07-21 20:49:38 223

原创 AtCoder Beginner Contest 310-D - Peaceful Teams(DFS)

There areNsports players.Among them, there areMincompatible pairs. Thei-th incompatible pair (1≤i≤M)is the Ai​-th andBi​-th players.You will divide the players intoTteams. Every player must belong to exactly one team, and every team must have

2023-07-19 18:14:25 1004

原创 牛客练习赛113--小红的数组操作(最短路)

第一行输入五个正整数n,p,x,q,y,n代表数组的大小,其余几个变量如题目描述所示。第二行输入n个正整数ai​,代表数组的元素。小红希望若干次操作后,数组的平均数是一个整数。你能帮小红求出最小的总代价吗?如果无解,请输出-1。否则输出一个整数,代表最小的总代价。1.选择一个元素,花费p,使其加x。1.选择一个元素,花费q,使其减y。

2023-07-08 11:17:13 1124 1

原创 Edu CF Round 88 --B. New Theatre Square(贪心orDP)

You might have remembered Theatre square from theproblem 1A. Now it's finally getting repaved.The square still has a rectangular shape ofn×m meters. However, the picture is about to get more complicated now. Letai,j be thej-th square in thei-th ro

2023-07-07 17:05:28 444

原创 Noobs Round #2 (Div. 4) by Rudro25--E. Password(DP)

You are given a string which is the hint of a password. Given string only consist of character '1' to '9' and '-'.You can replace '-' by any digit from '1' to '9'.Find the number of ways to make a password by replacing all '-' characters to some digit, suc

2023-07-06 20:14:00 152

原创 CF Round 777--C. Madoka and Childish Pranks

Madoka as a child was an extremely capricious girl, and one of her favorite pranks was drawing on her wall. According to Madoka's memories, the wall was a table ofnrows andmcolumns, consisting only of zeroes and ones. The coordinate of the cell in the

2023-07-03 12:11:47 307

原创 CF Round 821 (Div. 2)--C. Parity Shuffle Sorting

You are given an arrayawithnnon-negative integers. You can apply the following operation on it.Choose two indiceslandr (1≤l

2023-06-29 19:09:19 324

原创 CF Round 881 --E. Tracking Segments

You are given an arrayaconsisting ofnzeros. You are also given a set ofmnot necessarily different segments. Each segment is defined by two numbersli andri (1≤li≤ri≤n) and represents a subarrayali,ali+1,…,ar of the arraya.Let's call the segment

2023-06-22 18:19:06 384

原创 CF Round 881--D. Apple Tree

Timofey has an apple tree growing in his garden; it is a rooted tree ofnvertices with the root in vertex1(the vertices are numbered from1ton). A tree is a connected graph without loops and multiple edges.This tree is very unusual— it grows with i

2023-06-21 09:27:55 656

原创 CF Round 650 --C. Social Distance

Polycarp and his friends want to visit a new restaurant. The restaurant hasntables arranged along a straight line. People are already sitting at some tables. The tables are numbered from1tonin the order from left to right. The state of the restaurant

2023-06-19 12:04:05 232

空空如也

空空如也

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

TA关注的人

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