校队训练
文章平均质量分 57
追风者_
要我自我介绍,挺秃然的
展开
-
2021HDU多校 1008 Lawn of the Dead 线段树
思路:按照题意,如果一个格子的上方一个格子和左边一个格子都走不了,那这个格子就走不了,一旦一个格子走的了,其下面的格子都走的了,右边的格子也都走的了(地雷除外)。那么考虑用线段树维护一行中能走到的格子和走不到的,走得到的为0,走不到的为1。那么询问区间[l,r]看最左边的0在哪,这个0一路到r的格子就都可以走。询问的区间就是一行里面每两个地雷之间的区间。AC代码:#include<iostream>#include<string>#include<algorith原创 2021-07-31 20:02:01 · 234 阅读 · 0 评论 -
2021牛客多校5 D Double Strings dp 数学
思路:先预处理出dp[i][j]dp[i][j]dp[i][j]表示a的前i位和b的前j位能组成的相同子序列个数。然后对于每个a[i]<b[j]的位置,前面有dp[i−1][j−1]dp[i-1][j-1]dp[i−1][j−1]的方案数,乘上后面 ∑k=1min(len1−i,len2−j)Clen1kClen2k\sum_{k=1}^{min(len1-i,len2-j)}C_{len1}^{k}C_{len2}^{k}∑k=1min(len1−i,len2−j)Clen1kClen2k原创 2021-07-31 18:47:06 · 175 阅读 · 0 评论 -
2021HDU多校1 Xor sum 字典树
题意:问你能不能找到一个最小的区间【L,R】,使得区间异或和>=k,同时保证左端点最小。思路:选取区间[l,r][l,r][l,r],其值等效于sumr异或suml−1sum_r 异或 sum_{l-1}sumr异或suml−1,那我们就利用一个字典树,在枚举右端点时,查询满足与当前sumrsum_rsumr异或起来大于等于k且下标最大的前缀位置。插入时,每次更新走过当前路径上的点时的最大下标。这样在查询的时候,我们先贪心从高位开始走异或起来和k逐位相同的路线,然后看k该位为0时,我们若原创 2021-07-23 14:32:50 · 248 阅读 · 0 评论 -
CodeForces - 1191F Tokitsukaze and Strange Rectangle cdq分治
题意:选任意底长的框把若干点框起来,有多少种方法。思路:看到这种X-Y还带有计数的,想到cdq分治(二维偏序)。每次我就看xj<=xix_j <= x_ixj<=xi&&yj>=yiy_j>=y_iyj>=yi的点有多少,分别统计这个点左边有多少个、右边有多少个。然后左右的数量相乘就是以当前i为底的贡献。考虑到有y相同的,这里会产生重复,就需要统一特判一下所有y相同的,相邻两个间独立计数。AC代码:#include<iostrea原创 2021-05-29 21:11:36 · 181 阅读 · 0 评论 -
Points in Rectangle (II) LightOJ - 1267 树状数组 离散化
<font color=#000033 size=3=3 face=“黑体”>题意:给若干点和若干个矩形,问你每个矩形包含了多少个点思路:其实问题就转化成,对于每个矩形求横坐标∈[x1,x2x_1,x_2x1,x2],纵坐标满足∈[y1,y2y_1,y_2y1,y2]的点的个数。对点离散化后,我们先求[x1,x2x_1,x_2x1,x2]内纵坐标小于等于(y1-1)的个数,再求这个区间内小于等于y2的个数,后者-前者即是答案。考虑用树状数组维护,现在离散化后的x就是我们查询的区原创 2021-05-22 22:33:32 · 151 阅读 · 0 评论 -
【牛客多校 #7】 H Dividing 整数分块
链接:https://ac.nowcoder.com/acm/contest/5672/H来源:牛客网The following rules define a kind of integer tuple - the Legend Tuple:(1, k) is always a Legend Tuple, where k is an integer.if (n, k) is a Legend Tuple, (n + k, k) is also a Legend Tuple.if (n, k) is原创 2020-08-01 19:31:23 · 341 阅读 · 0 评论 -
【BAPC 2016 J】 Programming Tutors 二分图 二分答案
You are the founder of the Bruce Arden ProgrammingCollective, which is a tutoring programme that matchesexperienced programmers with newbies to teach them.You have N students and N tutors, but now you haveto match them up. Since the students will have原创 2020-07-23 17:02:30 · 264 阅读 · 0 评论 -
【BAPC 2016】 C. Brexit BFS(拓扑排序)
A long time ago in a galaxy far, far away, there was a large interstellar trading union, consistingof many countries from all across the galaxy. Recently, one of the countries decided to leavethe union. As a result, other countries are thinking about lea原创 2020-07-23 16:54:14 · 262 阅读 · 0 评论 -
【Maratona de Programa¸c˜ao da SBC 2019 A】Artwork 并查集 模拟
The Mona Dura is one of the most valuable artworks in Nlogonia Museum. The famous painting isdisplayed in a rectangular room of M by N meters. The room entrance is in a corner of it, while theMona is in the corner diagonally opposite to the entrance.To原创 2020-07-22 18:51:44 · 559 阅读 · 0 评论 -
【Maratona de Programa¸c˜ao da SBC 2019 M】 Maratona Brasileira de Popcorn 二分答案
The “Maratona Brasileira de Popcorn” is a competition that takes place annually to find out whichteam is the most organized, prepared and well-trained in the art of eating popcorn. It is organized byBrazilian Society of Popcorn Eaters (SBCp, its acronym原创 2020-07-22 16:36:12 · 395 阅读 · 0 评论 -
【暑训组队 #1】 Bonuses on a Line 二分
There are n bonuses on a line: the i-th bonus is located at the point xi. All coordinates of all bonuses are distinct. You are located at the point with the coordinate 0. How many bonuses can you collect in t seconds, if you can pass the distance 1 in one原创 2020-07-15 17:19:14 · 553 阅读 · 0 评论 -
【暑训组队 #1】 Array‘s Hash 树状数组
Vasya has invented a new hash function of an array. It is calculated as follows. While the array has at least two elements, the first two elements, call them a1 and a2, are deleted, and the new element a2−a1 is inserted to the beginning of the array. When原创 2020-07-15 17:08:12 · 241 阅读 · 0 评论 -
【暑训排位 #D】Gym - 100952H 动态规划DP
A sequence of positive and non-zero integers called palindromic if it can be read the same forward and backward, for example:15 2 6 4 6 2 1520 3 1 1 3 20We have a special kind of palindromic sequences, let’s call it a special palindrome.A palindromic s原创 2020-07-10 18:55:34 · 210 阅读 · 0 评论 -
【暑训排位赛 #A】Gym - 100971D 单调栈
One-dimensional country has n cities, the i-th of which is located at the point x i and has population p i, and all x i, as well as all p i, are distinct. When one-dimensional country got the Internet, it was decided to place the main server in the largest原创 2020-07-10 18:08:28 · 187 阅读 · 0 评论 -
【暑训排位 #9 F】 思维
You are given a permutation p of length n. Also you are given m foe pairs (a i, b i) (1 ≤ a i, b i ≤ n, a i ≠ b i).Your task is to count the number of different intervals (x, y) (1 ≤ x ≤ y ≤ n) that do not contain any foe pairs. So you shouldn’t count int原创 2020-07-08 17:45:35 · 192 阅读 · 0 评论 -
【暑训排位 #8 B】 二分图 最大匹配
Consider a town where all the streets are one-way and each street leads from one intersection to another. It is also known that starting from an intersection and walking through town’s streets you can never reach the same intersection i.e. the town’s stree原创 2020-07-07 18:26:43 · 147 阅读 · 0 评论 -
【暑训排位 #8 A】动态规划 LIS
In the army, a platoon is composed by n soldiers. During the morning inspection, the soldiers are aligned in a straight line in front of the captain. The captain is not satisfied with the way his soldiers are aligned; it is true that the soldiers are align原创 2020-07-07 18:12:44 · 229 阅读 · 1 评论 -
【暑训排位 #7 A】树状数组逆序对 异或求和 详解
给定长度为N的序列A1, A2, … AN,求其中xor是按位异或运算。题意:如题思路:1.如何对异或快速求和?这个地方推了好久。我们从异或的性质入手,一串数两两异或下来,一个规律是不会比这串数的最大值还大的(毕竟不会多1),另一个是对于每个位,只有当相异的时候才会有正贡献(废话)。那我们就按位分析。比如 111 101 100 (先看两两没有限制地异或,先不考虑Ai > Aj)我们拿低一位来看,一共有2个1,1个0,他们匹配的时候就有2*1种得到贡献的可能(01搭配),那么低一位就有原创 2020-07-06 17:34:23 · 362 阅读 · 0 评论 -
【暑训排位 #6 B】 排列组合
N boxes are lined up in a sequence (1 ≤ N ≤ 20). You have A red balls and B blue balls (0 ≤ A ≤ 15, 0 ≤ B ≤ 15). The red balls (and the blue ones) are exactly the same. You can place the balls in the boxes. It is allowed to put in a box, balls of the two k原创 2020-07-05 21:53:42 · 360 阅读 · 0 评论 -
【暑训排位 #5 D】 Jobbery tarjan 缩点
Hard times came for Martian senate. Even this pride of Martian democracy can not oppose the almighty jobbery. Let’s consider the procedure of typical decision making. A member of Martian senate, who needs a certain law, submits it to senate. To improve his原创 2020-07-04 20:00:19 · 164 阅读 · 0 评论 -
【暑训排位 #5 H】 Spy Syndrome 2 字典树 暴力优化
After observing the results of Spy Syndrome, Yash realised the errors of his ways. He now believes that a super spy such as Siddhant can’t use a cipher as basic and ancient as Caesar cipher. After many weeks of observation of Siddhant’s sentences, Yash det原创 2020-07-04 19:55:13 · 168 阅读 · 0 评论 -
【暑训排位 #5 F】 Balloons 贪心
As you may know, balloons are handed out during ACM contests to teams as they solve problems.However, this sometimes presents logistical challenges. In particular, one contest hosting site maintainstwo rooms, A and B, each containing a supply of balloons原创 2020-07-04 19:35:17 · 146 阅读 · 0 评论 -
【暑训排位 #4 D】树状数组
During several decades, scientists from planet Nibiru are working to create an engine that would allow spacecrafts to fall into hyperspace and move there with superluminal velocity. To check whether their understanding of properties of hyperspace is right,原创 2020-07-03 21:44:48 · 194 阅读 · 0 评论 -
【暑训排位 #4 F】 数位dp
Create a code to determine the amount of integers, lying in the set [ X; Y] and being a sum of exactly K different integer degrees of B.Example. Let X=15, Y=20, K=2, B=2. By this example 3 numbers are the sum of exactly two integer degrees of number 2:17原创 2020-07-03 21:33:39 · 153 阅读 · 0 评论 -
【暑训排位 #4 G】 欧几里得扩展
The number x is called an idempotent modulo n ifx* x = x (mod n)Write the program to find all idempotents modulo n, where n is a product of two distinct primes p and q.InputFirst line contains the number k of test cases to consider (1 ≤ k ≤ 1000). Each原创 2020-07-03 21:20:40 · 125 阅读 · 0 评论 -
【暑训排位#3 F】URAL - 1501 记忆化搜索
The owner of a casino for New Russians has a very refined sense of beauty. For example, after a game there remain two piles with the same number of cards on the table, and the owner likes the cards to be arranged into two piles according to the color: one原创 2020-06-27 19:24:06 · 128 阅读 · 0 评论 -
【暑训排位#3 B】 URAL - 1934 最短路
Bootstrap: Jones’s terrible leviathan will find you and drag the Pearl back to the depths and you along with it.Jack: Any idea when Jones might release said terrible beastie?Bootstrap: I already told you, Jack. Your time is up. It comes now, drawn with r原创 2020-06-27 18:18:42 · 154 阅读 · 0 评论 -
【暑训排位#3 A】 URAL - 1137 DFS
Several bus routes were in the city of Fishburg. None of the routes shared the same section of road, though common stops and intersections were possible. Fishburg old residents stated that it was possible to move from any stop to any other stop (probably m原创 2020-06-27 18:04:59 · 239 阅读 · 0 评论 -
【暑训个人赛#2 F】 POJ - 3352 Tarjan模板题
It’s almost summer time, and that means that it’s almost summer construction time! This year, the good people who are in charge of the roads on the tropical island paradise of Remote Island would like to repair and upgrade the various roads that lead betwe原创 2020-06-26 19:12:20 · 273 阅读 · 0 评论 -
【暑训个人赛#2 E】 HDU - 4135 容斥定理 唯一分解定理
Given a number N, you are asked to count the number of integers between A and B inclusive which are relatively prime to N.Two integers are said to be co-prime or relatively prime if they have no common positive divisors other than 1 or, equivalently, if t原创 2020-06-26 18:16:11 · 183 阅读 · 0 评论 -
【校队暑训个人赛 #1 H】 二分答案
A sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) are given. Write a program to find the minimal length of the subsequence of consecutive elements of the sequenc原创 2020-06-25 18:49:09 · 248 阅读 · 0 评论 -
【校队暑训个人赛 #1 B】 带权并查集
Now and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subsequence (for example the subsequence from the third to the fifth digit inclusively) and ask him, whethe原创 2020-06-25 18:40:51 · 130 阅读 · 0 评论 -
【Gym 102202】 D - A Plus Equals B
A + B is a problem used to test one’s basic knowledge for competitive programming. Here is yet another boring variation of it.You have two integers, A and B. You want to make them equal. To do so, you can perform several steps, where each step is one of t原创 2020-05-31 22:55:05 · 384 阅读 · 0 评论 -
【Gym 102202】 A - Rainbow Beads 规律 签到题
Jaehyun has a bead which consists of N jewels arranged from left to right. Each jewel is in one of the three colors: Red, Blue, and Violet, which is represented as a single character R, B, V. As one of the committees in an important contest, Jaehyun wants原创 2020-05-31 22:40:06 · 299 阅读 · 0 评论 -
【German Collegiate Programming Contest 2018 June 16th】 GCPC 2018 训练题 题解
Problem B: Battle RoyaleBattle Royale games are the current trend in video games and Gamers Concealed PunchingCircles (GCPC) is the most popular game of them all. The game takes place in an area that, forthe sake of simplicity, can be thought of as a tw原创 2020-05-30 22:19:51 · 995 阅读 · 0 评论 -
【Petrozavodsk Programming Camp, Winter 2020 Problem B】 Binomial DP 详解
There are people that wont be happy with solving a problem, unless the actual task is obscured by an elaborateand somewhat unnecessary story. If you are one of these people, then this problem is NOT for you.You are given a sequence of non-negative intege原创 2020-05-24 19:10:38 · 991 阅读 · 0 评论 -
Northwestern Europe Regional Contest (NWERC) 2018 B. Kattis - brexitnegotiations 拓扑排序 贪心
As we all know, Brexit negotiations are on their way—but we still do not know whether they will actually finish in time.The negotiations will take place topic-by-topic. To organise the negotiations in the most effective way, the topics will all be discuss原创 2020-05-17 22:47:29 · 377 阅读 · 0 评论 -
【HDU 1506】 Largest Rectangle in a Histogram 单调栈
题意:给出n个宽为1,长度为a[i]的矩形,求最大相连面积(如题图)思路(单调栈):首先,先观察到,我们,我们要选取的一个区间内的所有矩阵,其区间边界,肯定比区间内最小的矩阵高度还要小(不然就可以合并了)。然后问题就转化成了怎么求得当前位置左右第一个比它小的位置(相当于枚举每个位置当做区间内最小的那个元素然后*区间长度得到结果)。这就用到了单调栈。为什么可以用单调栈来解决呢?如果单纯暴力枚举每个位置的话左右第一个比它小的元素的话,是O(n2)的时间复杂度。 而由于有序列的连续性的限制,如果我们得到了.原创 2020-05-16 22:40:52 · 124 阅读 · 0 评论 -
【ICPC PACIFIC NORTHWEST REGION】L.Carry Cam Failure DFS 规律 思维
“Drat!” cursed Charles. “This stupid carry bar is not working in my Engine! I just tried to calculate the square of anumber, but it’s wrong; all of the carries are lost.”“Hmm,” mused Ada, “arithmetic without carries! I wonder if I can figure out what you原创 2020-05-16 20:38:28 · 472 阅读 · 0 评论 -
【ICPC PACIFIC NORTHWEST REGION】M. Maze Connect 并查集巧妙解法
Given an orthogonal maze rotated 45 degrees and drawn with forward and backward slash characters (see below),determine the minimum number of walls that need to be removed to ensure it is possible to escape outside of the mazefrom every square of the (pos原创 2020-05-16 19:47:18 · 581 阅读 · 0 评论