随笔分类 -  ACM-小技巧

摘要:思路分析 : 在二维中的接雨水,对每一个位置可以接水的量是其左侧的最大值和右侧的最大值中取小值 而在三维的接雨水中,首先可以知道的是最外面一层是不能接水的,因此对内层某一个位置的可以接水量,即为其四周高度的最小值决定的 我们可以借助优先队列,上来先将四周放入其中,取四周中最小的那个拿出来更新其邻域, 阅读全文
posted @ 2022-07-12 23:12 楼主好菜啊 阅读(77) 评论(0) 推荐(0) 编辑
摘要:思路分析 : 最后的答案一定是介于 1~n+1 之间,那么就可以将不在这个范围的数都变为 n+1,对于每个位置的数,不断的交换到它应该所在的位置 参考代码: class Solution { public: int firstMissingPositive(vector<int>& nums) { 阅读全文
posted @ 2021-11-07 22:09 楼主好菜啊 阅读(30) 评论(0) 推荐(0) 编辑
摘要:链接:https://ac.nowcoder.com/acm/contest/308/D来源:牛客网 题目描述 tokitsukaze给你一个长度为n的序列,这个序列是1到n的一种排列。 然后她会进行q次操作。每次操作会给你L R k这三个数,表示区间[L,R]往右移动k次。 移动一次的定义是:一个 阅读全文
posted @ 2018-12-08 12:05 楼主好菜啊 阅读(680) 评论(0) 推荐(0) 编辑
摘要:题意 : 可以选择操作一串区间,将区间内的某一个数全部变成一个新的数字,询问整个区间中某个数字的出现次数总共有多少个? 思路分析 : 首先最后选的一定是一个区间,然后 ans = cnt(1, l-1, c)+cnt(r+1, n, c)+cnt(l, r, d) ans = cnt(1, n, c 阅读全文
posted @ 2018-12-02 21:48 楼主好菜啊 阅读(133) 评论(0) 推荐(0) 编辑
摘要:链接:https://ac.nowcoder.com/acm/contest/217/B来源:牛客网 题目描述 msc和mcc是一对好朋友,有一天他们得到了一个长度为n的字符串s. 这个字符串s十分妙,其中只有’m’,’s’和’c’三种字符。 定义s[i,j]表示s中从第i个到第j个字符按顺序拼接起 阅读全文
posted @ 2018-11-10 10:02 楼主好菜啊 阅读(673) 评论(0) 推荐(0) 编辑
摘要:题目链接 Problem StatementWe will define the median of a sequence b of length M, as follows: Let b' be the sequence obtained by sorting b in non-decreasin 阅读全文
posted @ 2018-08-29 17:55 楼主好菜啊 阅读(303) 评论(0) 推荐(0) 编辑
摘要:Problem Statement There is an integer sequence of length 2N: A0,A1,…,A2N−1. (Note that the sequence is 0-indexed.) For every integer K satisfying 1≤K≤ 阅读全文
posted @ 2018-07-04 21:16 楼主好菜啊 阅读(252) 评论(0) 推荐(0) 编辑
摘要:链接:https://www.nowcoder.com/acm/contest/83/B来源:牛客网 题目描述 第一次期中考终于结束啦!沃老师是个语文老师,他在评学生的作文成绩时,给每位学生的分数都是一个小于10的非负小数。 Amy 8.9999999999999999999999999999999 阅读全文
posted @ 2018-04-17 21:39 楼主好菜啊 阅读(298) 评论(0) 推荐(0) 编辑
摘要:Jack Cheng学完了计算机基础导论,了解到任何一个数都可以用二进制数来表示,爱玩游戏的他忍不住想要玩一个游戏,既然可以用二进制数表示,那么就可以写成若干个二进制数相加,例如: 7=1+2+4 7=1+2+2+2 7=1+1+1+4 7=1+1+1+2+2、7=1+1+1+1+1+2 ,7=1+ 阅读全文
posted @ 2018-03-21 11:54 楼主好菜啊 阅读(790) 评论(0) 推荐(0) 编辑
摘要:Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try to reach one million by the process described belo 阅读全文
posted @ 2018-03-12 17:31 楼主好菜啊 阅读(183) 评论(0) 推荐(0) 编辑
摘要:Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift 阅读全文
posted @ 2018-03-12 09:19 楼主好菜啊 阅读(194) 评论(0) 推荐(0) 编辑
摘要:Dima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second 阅读全文
posted @ 2018-03-10 09:28 楼主好菜啊 阅读(213) 评论(0) 推荐(0) 编辑
摘要:The swimming area of Berhattan's city beach is marked out with n buoys. The buoys form a straight line. When the buoys were being put into the water, 阅读全文
posted @ 2018-02-22 16:22 楼主好菜啊 阅读(201) 评论(0) 推荐(0) 编辑
摘要:Define the simple skewness of a collection of numbers to be the collection's mean minus its median. You are given a list of n (not necessarily distinc 阅读全文
posted @ 2018-02-22 00:16 楼主好菜啊 阅读(148) 评论(0) 推荐(0) 编辑
摘要:You are given a sequence of n integers a1, a2, ..., an. Determine a real number x such that the weakness of the sequence a1 - x, a2 - x, ..., an - x i 阅读全文
posted @ 2018-02-21 18:32 楼主好菜啊 阅读(128) 评论(0) 推荐(0) 编辑
摘要:You are given two strings a and b. You have to remove the minimum possible number of consecutive (standing one after another) characters from string b 阅读全文
posted @ 2018-02-14 16:33 楼主好菜啊 阅读(165) 评论(0) 推荐(0) 编辑
摘要:C. Swap Adjacent Elements time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have an arr 阅读全文
posted @ 2018-02-03 15:16 楼主好菜啊 阅读(156) 评论(0) 推荐(0) 编辑
摘要:题目描述 小W在计算一个数列{An},其中A1=1,A2=2,An+2=An+1+An。尽管他计算非常精准,但很快他就弄混了自己的草稿纸,他找出了一些他计算的结果,但他忘记了这些都是数列中的第几项。 输入描述: 每行包括数列中的一项Ak(k<=100000)。 总行数T<=30。 输出描述: 对于每 阅读全文
posted @ 2018-02-03 14:31 楼主好菜啊 阅读(149) 评论(0) 推荐(0) 编辑
摘要:You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes. Your task is to 阅读全文
posted @ 2018-02-02 16:51 楼主好菜啊 阅读(850) 评论(0) 推荐(0) 编辑
摘要:Given a list of N integers with absolute values no larger than 10 15, find a non empty subset of these numbers which minimizes the absolute value of t 阅读全文
posted @ 2018-01-27 20:28 楼主好菜啊 阅读(369) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示