
暴力
文章平均质量分 54
旺 崽
这个作者很懒,什么都没留下…
展开
-
LeetCode 1178 猜字谜
题目链接外国友人仿照中国字谜设计了一个英文版猜字谜小游戏,请你来猜猜看吧。字谜的迷面 puzzle 按字符串形式给出,如果一个单词 word 符合下面两个条件,那么它就可以算作谜底:单词 word 中包含谜面 puzzle 的第一个字母。单词 word 中的每一个字母都可以在谜面 puzzle 中找到。例如,如果字谜的谜面是 “abcdefg”,那么可以作为谜底的单词有 “faced”, “cabbage”, 和 “baggage”;而 “beefed”(不含字母 “a”)以及 “based”(其原创 2021-03-11 19:22:22 · 1781 阅读 · 0 评论 -
LeetCode 131 分割回文串
LeetCode 131 分割回文串题目链接给你一个字符串 s,请你将 s 分割成一些子串,使每个子串都是 回文串 。返回 s 所有可能的分割方案。回文串是正着读和反着读都一样的字符串。示例 1:输入:s = "aab"输出:[["a","a","b"],["aa","b"]]示例 2:输入:s = "a"输出:[["a"]]暴力所有分隔符,显然对一个长为 nnn 的字符串最多可以划分成 nnn 个子串,那么我们就可以暴力所有的可能,复杂度 O(2n)O(2^n)O(2n)~注意最原创 2021-03-09 09:19:00 · 1770 阅读 · 0 评论 -
LeetCode 1774 最接近目标价格的甜点成本
题目链接你打算做甜点,现在需要购买配料。目前共有 n 种冰激凌基料和 m 种配料可供选购。而制作甜点需要遵循以下几条规则:必须选择 一种 冰激凌基料。可以添加 一种或多种 配料,也可以不添加任何配料。每种类型的配料最多两份 。给你以下三个输入:baseCosts ,一个长度为 n 的整数数组,其中每个 baseCosts[i] 表示第 i 种冰激凌基料的价格。toppingCosts,一个长度为 m 的整数数组,其中每个 toppingCosts[i] 表示 一份 第 i 种冰激凌配料的原创 2021-03-06 10:57:37 · 1725 阅读 · 0 评论 -
LeetCode 85 最大矩形
LeetCode 85 最大矩形题目链接给定一个仅包含 0 和 1 、大小为 rows x cols 的二维二进制矩阵,找出只包含 1 的最大矩形,并返回其面积。示例 1:输入:matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]输出:6解释:最大矩形如上图所示。示例 2:输入:matrix = []输出:0示例 3:输入:matrix原创 2021-01-24 17:31:44 · 1747 阅读 · 0 评论 -
LeetCode 5662 满足三条件之一需改变的最少字符数
LeetCode 5662 满足三条件之一需改变的最少字符数题目链接给你两个字符串 a 和 b ,二者均由小写字母组成。一步操作中,你可以将 a 或 b 中的 任一字符 改变为 任一小写字母 。操作的最终目标是满足下列三个条件 之一 :a 中的 每个字母 在字母表中 严格小于 b 中的 每个字母。b 中的 每个字母 在字母表中 严格小于 a 中的 每个字母。a 和 b 都 由 同一个 字母组成。返回达成目标所需的 最少 操作数。示例 1:输入:a = "aba", b = "caa"原创 2021-01-24 16:04:22 · 1841 阅读 · 0 评论 -
牛客练习赛76 A.校园活动
牛客练习赛76 A.校园活动题目链接题目描述牛牛中学为了给本校的OIer放松心情,决定举报一场校园活动。现在学校的共有 个OIer,学校想把他们分为一些小组进行一个团队游戏。学校先了解了一下每个同学对这个团队游戏的了解程度。为了游戏的公平,学校需要使分组后的每一个小组内所有人对游戏的了解程度之和相等,但同学们并不希望完全由学校来给他们分组,所以这 个人站为了一行,学校只能将队列中一段完整的子队列作为一个小组。换句话说,如果你想让位置为 xxx 和 yyy 的人在一个小组里,你就必须让 xxx 和原创 2021-01-15 23:59:21 · 2456 阅读 · 0 评论 -
2020 China Collegiate Programming Contest - Mianyang Site J. Joy of Handcraft
2020 China Collegiate Programming Contest - Mianyang Site J. Joy of Handcraft题目链接Little Horse always does some handcrafts, which is full of joy. This time, he builds a circuit that can turn on and off the bulbs periodically.There are n bulbs in the circ原创 2020-12-09 23:21:13 · 2396 阅读 · 0 评论 -
The 2019 China Collegiate Programming Contest Harbin Site F. Fixing Banners
The 2019 China Collegiate Programming Contest Harbin Site F. Fixing Banners题目链接Harbin, whose name was originally a Manchu word meaning “a place for drying fishing nets”, grew from a small rural settlement on the Songhua River to become one of the largest原创 2020-10-03 19:08:23 · 3531 阅读 · 0 评论 -
Codeforces Round #674 (Div. 3) E. Rock, Paper, Scissors
Codeforces Round #674 (Div. 3) E. Rock, Paper, Scissors题目链接Alice and Bob have decided to play the game “Rock, Paper, Scissors”.The game consists of several rounds, each round is independent of each other. In each round, both players show one of the foll原创 2020-10-01 18:36:55 · 2531 阅读 · 0 评论 -
AtCoder Beginner Contest 178 E.Dist Max
AtCoder Beginner Contest 178题目链接如果我们知道一个 nnn 维的点,对每一个维度都有一个运算符的话,很明显一共有 2n2^n2n 种运算,而曼哈顿距离就是这些运算结果的最大值和最小值之差,那么对本题只需要枚举所有情况算最大差值即可,AC代码如下:#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=2e5+5;ll a[N][2];int n;ll原创 2020-09-15 09:21:06 · 2587 阅读 · 0 评论 -
AtCoder Beginner Contest 178 F.Contrast
AtCoder Beginner Contest 178 F.Contrast题目链接这题我用的是一个个换位然后比较,结果 T 了四个,赛后看别人的题解,发现也是伪暴力的做法,不知道为啥就能过????题目已经按递增序给出两个数组,我们可以将数组 B 倒置,逐个与数组 A 比较,如果相同就遍历整个数组找出不同的元素进行换位,找不到直接输出 NoNoNo,最后输出 B 即可,AC代码如下:#include<bits/stdc++.h>using namespace std;typede原创 2020-09-15 09:06:19 · 2489 阅读 · 0 评论 -
HDUOJ 6573 Traffic
HDUOJ 6573 Traffic题目链接Problem DescriptionAvin is observing the cars at a crossroads. He finds that there are n cars running in the east-west direction with the i-th car passing the intersection at time ai . There are another m cars running in the north-原创 2020-08-31 15:14:28 · 2412 阅读 · 0 评论 -
牛客编程巅峰赛S1第11场 - 黄金&钻石 B.新集合
牛客编程巅峰赛S1第11场 - 黄金&钻石 B.新集合题目链接题目描述集合 s 中有整数 1 到 n,牛牛想从中挑几个整数组成一个新的集合。现在牛妹给牛牛加了 m 个限制 ,每个限制包含两个整数 u 和 v (u≠v)( u\neq v)(u=v),且 u 和 v 不能同时出现在新集合中 。请问牛牛能组成的新集合多少种。可以选 0 个数输入第一个参数为 n。第二个参数为 m 。第三个参数为 m 对 (u, v) 。1<n≤201≤m≤4001≤u,v≤n1 <原创 2020-08-14 09:41:11 · 2476 阅读 · 0 评论 -
2020牛客暑期多校训练营(第十场)A.Permutation
2020牛客暑期多校训练营(第十场)A.Permutation题目链接题目描述You are given a prime number p, you want to find a permutation of numbers 1,2,…,p−11, 2, \dots, p-11,2,…,p−1, denoted as x1,x2,…,xp−1x_1, x_2, \dots, x_{p-1}x1,x2,…,xp−1, such that for all i(1≤i≤p−2)i (1\leq i\l原创 2020-08-10 20:30:24 · 2785 阅读 · 0 评论 -
2020牛客暑期多校训练营(第十场)E.Game
2020牛客暑期多校训练营(第十场)E.Game题目链接题目描述There are n columns of blocks standing in a row. The i-th column has aia_iai blocks in the beginning. Each block has size 1×1×11\times 1\times 11×1×1. Define (x,y) represent the block at column x and is the y-th block fr原创 2020-08-10 20:08:26 · 2597 阅读 · 1 评论 -
Educational Codeforces Round 92 (Rated for Div. 2) C. Good String
Educational Codeforces Round 92 (Rated for Div. 2) C. Good String题目链接Let’s call left cyclic shift of some string t1t2t3…tn−1tn as string t2t3…tn−1tnt1.Analogically, let’s call right cyclic shift of string t as string tnt1t2t3…tn−1.Let’s say string t原创 2020-08-02 10:26:04 · 2652 阅读 · 0 评论 -
HDUOJ 6789 Fight
HDUOJ 6789 Fight题目链接Problem DescriptionMr Left,Mr Mid,Mr Right 正在玩游戏。他们初始都有 1000 血,Mr Left,Mr Mid,Mr Right 的攻击力分别为 x,y,z。对于每一轮,假设仍然剩下至少两个人的血量大于 0,那么选出两个血量大于 0 的人对打,他们的血量分别扣除和他们对打的另一个人的攻击力。当有至少两个人的血量小于等于 0 时,游戏结束。请问在最优情况下,这个游戏最少多少轮结束?Input第一行一个正整数 t原创 2020-07-28 19:03:08 · 2465 阅读 · 0 评论 -
Codeforces Round #657 (Div. 2) A. Acacius and String
Codeforces Round #657 (Div. 2) A. Acacius and String题目链接Acacius is studying strings theory. Today he came with the following problem.You are given a string s of length n consisting of lowercase English letters and question marks. It is possible to repla原创 2020-07-24 10:46:31 · 2429 阅读 · 0 评论 -
智算之道模拟赛 B.公交换乘
智算之道模拟赛 B.公交换乘题目链接【问题描述】著名旅游城市 B 市为了鼓励大家采用公共交通方式出行,推出了一种地铁换乘公交车的优惠方案:1.在搭乘一次地铁后可以获得一张优惠票,有效期为 45 分钟,在有效期内可以消耗这张优惠票,免费搭乘一次票价不超过地铁票价的公交车。在有效期内指开始乘公交车的时间与开始乘地铁的时间之差小于等于 45 分钟,即:2.搭乘地铁获得的优惠票可以累积,即可以连续搭乘若干次地铁后再连续使用优惠票搭乘公交车。3.搭乘公交车时,如果可以使用优惠票一定会使用优惠票;如果有多张原创 2020-07-09 10:38:36 · 2626 阅读 · 0 评论 -
2019牛客暑期多校训练营(第七场)A.String
2019牛客暑期多校训练营(第七场)A.String题目链接题目描述A string is perfect if it has the smallest lexicographical ordering among its cyclic rotations.For example: “0101” is perfect as it is the smallest string among (“0101”, “1010”, “0101”, “1010”).Given a 01 string, you原创 2020-07-06 18:29:05 · 2376 阅读 · 0 评论 -
AtCoder Beginner Contest 173 E.Multiplication 4
AtCoder Beginner Contest 173 E.Multiplication 4题目链接题意很简单,这题就和蓝桥杯的一道题一模一样,直接枚举即可,将数组排序后,每次从头选两个数相乘从尾部选两个数相乘比较大小即可,AC代码如下:#include <bits/stdc++.h>using namespace std;typedef long long ll;const ll mod=1e9+7;int main() { int n,k; scanf("%d%d",&原创 2020-07-06 17:06:23 · 2508 阅读 · 0 评论 -
2019牛客暑期多校训练营(第六场)D.Move
2019牛客暑期多校训练营(第六场)D.Move题目链接题目描述After the struggle of graduating from college, TangTang is about to move from a student apartment to his new home.TangTang has n items to move, the i-th of which is of volume viv_ivi. He can pack all these items into at原创 2020-06-30 18:09:02 · 2478 阅读 · 0 评论 -
2019牛客暑期多校训练营(第四场)C.sequence
2019牛客暑期多校训练营(第四场)C.sequence题目链接题目描述Your are given two sequences a1…na_{1 \dots n}a1…n and b1…nb_{1 \dots n}b1…n.You need to answer max1≤l≤r≤n{min(al…r)×sum(bl…r)}\displaystyle \max_{1 \le l \le r \le n} \{min(a_{l \dots r}) \times sum(b_{l \dots r})原创 2020-06-29 10:20:53 · 2415 阅读 · 0 评论 -
AtCoder Beginner Contest 172 D.Sum of Divisors
AtCoder Beginner Contest 172 D.Sum of Divisors题目链接直接暴力出 1e7 内的所有数的因子数,暴力计算即可:#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=1e7+5;ll f[N],n,ans;int main(){ for(int i=1;i<N;i++) for(int j=i;j<N;j+=i) f[j]原创 2020-06-28 09:22:42 · 2545 阅读 · 0 评论 -
The Preliminary Contest for ICPC Asia Shanghai 2019 L. Digit sum
The Preliminary Contest for ICPC Asia Shanghai 2019 L. Digit sum题目链接A digit sum Sb(n)S_b(n)Sb(n) is a sum of the base-bb digits of nn. Such as S10(233)=2+3+3=8S_{10}(233) = 2 + 3 + 3 = 8S10(233)=2+3+3=8, S2(8)=1+0+0=1S_{2}(8)=1 + 0 + 0 = 1S2(8)=1+0+0=原创 2020-06-25 09:41:46 · 2343 阅读 · 0 评论 -
The Preliminary Contest for ICPC Asia Nanjing 2019 F. Greedy Sequence
The Preliminary Contest for ICPC Asia Nanjing 2019 F.Greedy Sequence题目链接You’re given a permutation aa of length n(1≤n≤105)n (1 \le n \le 10^5)n(1≤n≤105).For each i∈[1,n]i\in [1,n]i∈[1,n], construct a sequence sis_isi by the following rules:si[1]=is原创 2020-06-24 10:50:30 · 2330 阅读 · 0 评论 -
2019牛客暑期多校训练营(第二场)F.Partition problem
2019牛客暑期多校训练营(第二场)F.Partition problem题目链接题目描述Given 2N people, you need to assign each of them into either red team or white team such that each team consists of exactly N people and the total competitive value is maximized.Total competitive value is th原创 2020-06-19 21:01:31 · 2366 阅读 · 0 评论 -
2019牛客暑期多校训练营(第二场)H.Second Large Rectangle
2019牛客暑期多校训练营(第二场)H.Second Large Rectangle题目链接题目描述Given a N×MN \times MN×Mbinary matrix. Please output the size of second large rectangle containing all "1"\texttt{"1"}"1".Containing all "1"\texttt{"1"}"1" means that the entries of the rectangle are al原创 2020-06-19 15:20:38 · 2351 阅读 · 0 评论 -
Codeforces Round #598 (Div. 3) B.Minimize the Permutation
Codeforces Round #598 (Div. 3) B.Minimize the Permutation题目链接You are given a permutation of length n. Recall that the permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but原创 2020-05-26 16:33:41 · 2387 阅读 · 0 评论 -
Codeforces Round #640 (Div. 4) E.Special Elements
Codeforces Round #640 (Div. 4) E.Special Elements题目链接Pay attention to the non-standard memory limit in this problem.In order to cut off efficient solutions from inefficient ones in this problem, the time limit is rather strict. Prefer to use compiled st原创 2020-05-13 14:33:10 · 19005 阅读 · 1 评论 -
Panasonic Programming Contest 2020 E.Three Substrings
Panasonic Programming Contest 2020 E.Three Substrings题目链接这题考虑到贪心会有疏漏,加上数据范围比较小,所以考虑穷搜,即记录下所有冲突位置,ababab 数组记录字符串 aaa 和 bbb 中不同的元素的位置,acacac 数组和 bcbcbc 数组同理下面考虑将字符串 bbb 和 ccc 这两个字符串插入到 aaa 的两侧,则最大范围...原创 2020-04-25 15:58:14 · 2348 阅读 · 0 评论 -
Codeforces Round #635 (Div. 2) B.Kana and Dragon Quest game
Codeforces Round #635 (Div. 2) B.Kana and Dragon Quest game原创 2020-04-16 17:37:56 · 2461 阅读 · 0 评论 -
AtCoder Beginner Contest 162 D.RGB Triplets
AtCoder Beginner Contest 162 D.RGB Triplets题目链接Problem StatementWe have a string S of length N consisting of R, G, and B.Find the number of triples (i,j,k) (1≤i<j<k≤N)(i, j, k) \ (1≤i&l...原创 2020-04-13 13:14:45 · 2723 阅读 · 3 评论 -
HDUOJ 4847 Wow! Such Doge!
HDUOJ 4847 Wow! Such Doge!题目链接Problem DescriptionChen, Adrian (November 7, 2013). “Doge Is An Ac- tually Good Internet Meme. Wow.”. Gawker. Retrieved November 22, 2013.Doge is an Internet meme th...原创 2020-04-02 15:28:28 · 2465 阅读 · 0 评论 -
Codeforces Round #629 (Div. 3) B.K-th Beautiful String
Codeforces Round #629 (Div. 3) B.K-th Beautiful StringFor the given integer n (n>2) let’s write down all the strings of length n which contain n−2 letters ‘a’ and two letters ‘b’ in lexicographica...原创 2020-03-27 08:43:05 · 2441 阅读 · 0 评论 -
Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) B.Count Subrectangles
Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) B.Count SubrectanglesYou are given an array a of length n and array b of length m both consisting of only integers 0 and 1...原创 2020-03-08 10:22:47 · 2451 阅读 · 0 评论 -
牛客小白月赛22 D.收集纸片
牛客小白月赛22 D.收集纸片题目描述我们把房间按照笛卡尔坐标系进行建模之后,每个点就有了一个坐标。假设现在房子里有些纸片需要被收集,收集完纸片你还要回归到原来的位置,你需要制定一个策略来使得自己行走的距离最短。你只能沿着 x 轴或 y 轴方向移动,从位置 (i,j) 移动到相邻位置 (i+1,j),(i-1,j),(i,j+1) 或 (i,j-1) 距离增加 1。输入描述:在第一行中...原创 2020-02-23 15:45:53 · 2888 阅读 · 0 评论 -
Codeforces Round #619 (Div. 2) B.Motarack's Birthday
Codeforces Round #619 (Div. 2) B.Motarack’s BirthdayDark is going to attend Motarack’s birthday. Dark decided that the gift he is going to give to Motarack is an array a of n non-negative integers.D...原创 2020-02-19 16:18:16 · 2841 阅读 · 0 评论 -
PAT甲级 1002 A+B for Polynomials
PAT甲级 1002 A+B for PolynomialsThis time, you are supposed to find A+B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and e...原创 2020-01-30 17:28:02 · 2596 阅读 · 0 评论 -
POJ 3347 Kadj Squares
POJ 3347 Kadj SquaresDescriptionIn this problem, you are given a sequence S1,S2,...,SnS_1, S_2, ..., S_nS1,S2,...,Sn of squares of different sizes. The sides of the squares are integer numbers. W...原创 2020-01-29 11:42:38 · 2646 阅读 · 0 评论