04 2021 档案
蚯蚓(队列)
摘要:原题链接 https://ac.nowcoder.com/acm/problem/16430 思路 这个题首先想到的用堆来维护,对于每一次操作,首先将当前的堆顶拿出来切成两半,再将两段插入堆中。这里堆的节点要记录这的点在0时刻的长度是多少,用来计算在第m秒的时候蚯蚓的长度。但是!但是一看数据范围,堆 阅读全文
posted @ 2021-04-28 21:31 Laurance 阅读(77) 评论(0) 推荐(0)
Operating System(堆,贪心)
摘要:原题链接 https://ac.nowcoder.com/acm/problem/15688 思路 如果内存没有满,很简单,直接将数放到内存中即可。问题在于慢了之后替换的时候替换内存中的哪一个数?这里的贪心思路是替换当前内存中下一次出现时间最晚的那个数,这可以用一个堆来维护,注意:如果当前的询问已经 阅读全文
posted @ 2021-04-26 17:38 Laurance 阅读(114) 评论(0) 推荐(0)
栈和排序(栈的应用)
摘要:原题链接 https://ac.nowcoder.com/acm/problem/blogs/14893 思路 处理一下每一个数字后面的最大数,然后根据顺序入栈,判断当前这个位置后面最大的元素和当前的栈顶元素,只要当前栈顶元素大于这个最大数就弹出,直到栈顶元素小于当前的m[i + 1]; 代码 #i 阅读全文
posted @ 2021-04-25 20:02 Laurance 阅读(121) 评论(0) 推荐(0)
加边的无向图(并查集)
摘要:原题链接 https://ac.nowcoder.com/acm/problem/14685 思路 并查集模板题,只需要把有边连接的点都添加到一个祖宗节点下,然后扫一遍所有点,只要遇到祖宗节点不是起始点的就添加一条边。 代码 #include <iostream> using namespace s 阅读全文
posted @ 2021-04-25 18:24 Laurance 阅读(77) 评论(0) 推荐(0)
vector的使用
摘要:原题链接 https://ac.nowcoder.com/acm/problem/14661 思路 主要是熟悉vector中的操作,其中reverse是头文件algorithm中的,vector类和string类中并没有reverse 可以参考:https://blog.csdn.net/qq_50 阅读全文
posted @ 2021-04-25 17:46 Laurance 阅读(50) 评论(0) 推荐(0)
经商
摘要:原题链接 https://ac.nowcoder.com/acm/problem/14545 思路 先用并查集维护一下所有从1能走到的点,每次给出两个点,就将这两个点的祖宗节点维护,最后对于所有的1到n号点,用01背包做一次,只要祖宗节点和1号点一样,就代表能走到,就可以放到背包考虑。 代码 #in 阅读全文
posted @ 2021-04-25 16:53 Laurance 阅读(60) 评论(0) 推荐(0)
C. Product 1 Modulo N
摘要:原题链接 https://codeforces.ml/contest/1514/problem/C Now you get Baby Ehab's first words: "Given an integer n, find the longest subsequence of [1,2,…,n−1 阅读全文
posted @ 2021-04-20 17:31 Laurance 阅读(287) 评论(0) 推荐(0)
B. AND 0, Sum Big
摘要:原题链接 https://codeforces.ml/contest/1514/problem/B Baby Badawy's first words were "AND 0 SUM BIG", so he decided to solve the following problem. Given 阅读全文
posted @ 2021-04-20 16:27 Laurance 阅读(159) 评论(0) 推荐(0)
A. Perfectly Imperfect Array
摘要:原题链接 https://codeforces.ml/contest/1514/problem/A Given an array a of length n, tell us whether it has a non-empty subsequence such that the product o 阅读全文
posted @ 2021-04-20 16:13 Laurance 阅读(158) 评论(0) 推荐(0)
源程序
该文被密码保护。
posted @ 2021-04-19 21:37 Laurance 阅读(0) 评论(0) 推荐(0)
七段码
摘要:题目描述 小蓝要用七段码数码管来表示一种特殊的文字。 上图给出了七段码数码管的一个图示,数码管中一共有 7 段可以发光的二 极管,分别标记为 a, b, c, d, e, f, g。 小蓝要选择一部分二极管(至少要有一个)发光来表达字符。在设计字符的表达时,要求所有发光的二极管是连成一片的。 例如: 阅读全文
posted @ 2021-04-13 14:36 Laurance 阅读(1666) 评论(1) 推荐(0)
I.找路(Roads? Where We Are Going, We Don’t Need Roads.)
摘要:题目描述 The National Road Service (NRS) wanted to make some changes to make sure that people are correctly ocially distancing from each other. However, N 阅读全文
posted @ 2021-04-10 17:18 Laurance 阅读(304) 评论(0) 推荐(0)
E.税收问题(Pesky Publicans)
摘要:题目描述 Tax collectors in the Roman empire, called publicans, are not well perceived, and for good reason. However, they are necessary for the running of 阅读全文
posted @ 2021-04-10 15:27 Laurance 阅读(74) 评论(0) 推荐(0)
H.蹦床跳跃(Jump Conveyor)
摘要:题目描述 Emma is a creative child who got bored during the quarantine season. She set up n trampolines in a line inside the living room, each aimed in a p 阅读全文
posted @ 2021-04-10 15:15 Laurance 阅读(158) 评论(0) 推荐(0)
I
摘要:题目描述 Listening to the rock music permutes your nuclear DNA. This astonishing and unbelievable fact was recently published in the Rock Nature Weekly, o 阅读全文
posted @ 2021-04-09 14:34 Laurance 阅读(389) 评论(0) 推荐(0)
F
摘要:题目描述 Boris is the chief executive officer of Rock Anywhere Transport (RAT) company which specializes in supporting music industry. In particular, they 阅读全文
posted @ 2021-04-08 17:27 Laurance 阅读(429) 评论(0) 推荐(0)
A
摘要:题目描述 Fernando was hired by the University of Waterloo to finish a development project the university started some time ago. Outside the campus, the un 阅读全文
posted @ 2021-04-07 20:55 Laurance 阅读(78) 评论(0) 推荐(0)
A
摘要:题目描述 Carryless addition is the same as normal addition, except any carries are ignored (in base 10). Thus, 37 + 48 is 75, not 85. Carryless multiplica 阅读全文
posted @ 2021-04-07 17:52 Laurance 阅读(138) 评论(0) 推荐(0)
J
摘要:题目描述 You are given a sequence of n integers x = [x1,x2,...,xn] and an integer k . It is guaranteed that 1 ≤ xi ≤ k , and every integer from 1 to k app 阅读全文
posted @ 2021-04-07 15:22 Laurance 阅读(145) 评论(0) 推荐(0)
D
摘要:题目描述 A set of words is called swap free if there is no way to turn any word in the set into any other word in the set by swapping only a single pair o 阅读全文
posted @ 2021-04-07 15:12 Laurance 阅读(83) 评论(0) 推荐(1)