摘要: There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. F... 阅读全文
posted @ 2018-03-22 23:33 StarHai 阅读(268) 评论(0) 推荐(0) 编辑
摘要: There are n men ,every man has an ID(1..n).their ID is unique. Whose ID is i and i-1 are friends, Whose ID is i and i+1 are friends. These n men stand 阅读全文
posted @ 2018-03-22 23:29 StarHai 阅读(329) 评论(0) 推荐(0) 编辑
摘要: 给你一个长度为N的序列ai,1≤i≤N和q组询问,每组询问读入l1,r1,l2,r2,需输出get(l,r,x)表示计算区间[l,r]中,数字x出现了多少次。Input第一行,一个数字N,表示序列长度。第二行,N个数字,表示a1~aN第三行,一个数字Q,表示询问个数。... 阅读全文
posted @ 2018-03-20 17:19 StarHai 阅读(294) 评论(0) 推荐(0) 编辑
摘要: Bob has a favorite number k and ai of length n. Now he asks you to answer m queries. Each query is given by a pair li and ri and asks ... 阅读全文
posted @ 2018-03-20 17:12 StarHai 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 某天,Lostmonkey发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀请小绵羊一起玩个游戏。游戏一开始,Lostmonkey在地上沿着一条直线摆上n个装置,每个装置设定初始弹力系数ki,当绵羊达到第i个装置时,它会往后弹ki步,达到第i+ki个装置,若不存... 阅读全文
posted @ 2018-03-12 23:38 StarHai 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 我很弱,但是我要坚强!绝不让那些为我付出过的人失望图的存储结构之邻接表(详解)之前我们介绍过图的邻接矩阵存储法,它的空间和时间复杂度都是N2,现在我来介绍另外一种存储图的方法:邻接表,这样空间和时间复杂度就都是M。对于稀疏图来说,M要远远小于N2。先上数据,如下。12... 阅读全文
posted @ 2018-03-09 21:55 StarHai 阅读(324) 评论(0) 推荐(0) 编辑
摘要: A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has alread... 阅读全文
posted @ 2018-03-09 21:48 StarHai 阅读(313) 评论(0) 推荐(0) 编辑
摘要: You are preparing for an exam on scheduling theory. The exam will last for exactly Tmilliseconds and will consist of n problems. You can either solve 阅读全文
posted @ 2018-03-09 21:45 StarHai 阅读(315) 评论(0) 推荐(0) 编辑
摘要: There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the typ... 阅读全文
posted @ 2018-03-09 21:42 StarHai 阅读(211) 评论(0) 推荐(0) 编辑
摘要: You have a rooted tree consisting of n vertices. Each vertex of the tree has some color. We will assume that the tree vertices are numbered by integer 阅读全文
posted @ 2018-03-09 21:38 StarHai 阅读(262) 评论(0) 推荐(0) 编辑
摘要: 度度熊喜欢着喵哈哈村的大明星——星星小姐。 为什么度度熊会喜欢星星小姐呢? 首先星星小姐笑起来非常动人,其次星星小姐唱歌也非常好听。 但这都不是最重要的,最重要的是,星星小姐拍的一手好代码! 于是度度熊关注了星星小姐的贴吧。 一开始度度熊决定每天都在星星小姐的贴吧里面签到。 但是度度熊是一个非常健忘 阅读全文
posted @ 2018-03-04 23:14 StarHai 阅读(327) 评论(0) 推荐(0) 编辑
摘要: 我们将A省简化为由N个城市组成,某些城市之间存在双向道路,而且A省的交通有一个特点就是任意两个城市之间都能通过道路相互到达,且在不重复经过城市的情况下任意两个城市之间的到达方案都是唯一的。聪明的你一定已经发现,这些城市构成了树这样一个结构。 现在百度陆续开了许许多多的... 阅读全文
posted @ 2018-03-04 23:07 StarHai 阅读(192) 评论(0) 推荐(0) 编辑
摘要: I hope you know the beautiful Union-Find structure. In this problem, you’re to implement somethingsimilar, but not identical.The data ... 阅读全文
posted @ 2018-03-04 23:02 StarHai 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 度度熊是一个喜欢计算机的孩子,在计算机的世界中,所有事物实际上都只由0和1组成。 现在给你一个n*m的图像,你需要分辨他究竟是0,还是1,或者两者均不是。 图像0的定义:存在1字符且1字符只能是由一个连通块组成,存在且仅存在一个由0字符组成的连通块完全被1所包围。 图... 阅读全文
posted @ 2018-03-04 23:00 StarHai 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 車是中国象棋中的一种棋子,它能攻击同一行或同一列中没有其他棋子阻隔的棋子。一天,小度在棋盘上摆起了许多車……他想知道,在一共N×M个点的矩形棋盘中摆最多个数的車使其互不攻击的方案数。他经过思考,得出了答案。但他仍不满足,想增加一个条件:对于任何一个車A,如果有其他一个... 阅读全文
posted @ 2018-03-04 22:54 StarHai 阅读(210) 评论(0) 推荐(0) 编辑
摘要: The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he ... 阅读全文
posted @ 2018-03-04 22:45 StarHai 阅读(157) 评论(0) 推荐(0) 编辑
摘要: We have a 3×3 grid. A number ci,j is written in the square (i,j), where (i,j) denotes the square at the i-th row from the top and the ... 阅读全文
posted @ 2018-03-04 22:41 StarHai 阅读(265) 评论(0) 推荐(0) 编辑
摘要: Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.Constraints1≤N≤1016N is an integer.I... 阅读全文
posted @ 2018-03-04 22:35 StarHai 阅读(233) 评论(0) 推荐(0) 编辑
摘要: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game mast... 阅读全文
posted @ 2018-03-04 22:24 StarHai 阅读(248) 评论(0) 推荐(0) 编辑
摘要: Farmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located along a straight line at positions x1,...,xN (0 <= xi 阅读全文
posted @ 2018-01-29 22:20 StarHai 阅读(383) 评论(0) 推荐(0) 编辑
摘要: Farmer John is an astounding accounting wizard and has realized he might run out of money to run the farm. He has already calculated and recorded the 阅读全文
posted @ 2018-01-29 21:54 StarHai 阅读(291) 评论(0) 推荐(0) 编辑
摘要: Demy has n jewels. Each of her jewels has some value vi and weight wi. Since her husband John got broke after recent financial crises, Demy has decide 阅读全文
posted @ 2018-01-29 21:34 StarHai 阅读(225) 评论(0) 推荐(0) 编辑
摘要: The SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute how many quadruplet (a, b, c, d ) ∈ A x B x C x D 阅读全文
posted @ 2018-01-29 20:52 StarHai 阅读(416) 评论(0) 推荐(0) 编辑
摘要: Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point loca... 阅读全文
posted @ 2018-01-29 20:44 StarHai 阅读(143) 评论(0) 推荐(0) 编辑
摘要: Give you three sequences of numbers A, B, C, then we give you a number X. Now you need to calculate if you can find the three numbers ... 阅读全文
posted @ 2018-01-29 20:44 StarHai 阅读(231) 评论(0) 推荐(0) 编辑