摘要:
Description Description 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种 阅读全文
摘要:
There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other. We say t 阅读全文
摘要:
The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ag 阅读全文
摘要:
You are assigned to design network connections between certain points in a wide area. You are given a set of points in the area, and a set of possible 阅读全文
摘要:
今天学习了有点骚气的树状数组(其实学了几天了,今天才理解) Problem Description N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lel 阅读全文
摘要:
在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。 你的任务是,对于给定的N,求出有多少种合法的放置方法。 Input共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。Output共有若 阅读全文
摘要:
思路:这道题无法用平时0(n^2)的解法来求最长上升子序列,会超时,只能用优化的最长上升子序列算法来求 You are given a problemset consisting of nn problems. The difficulty of the ii -th problem is aiai 阅读全文
摘要:
思路:这道题要重复数字的下标存起来,把没出现过的数字标记起来并且存起来,然后再把重复的数字换成没出现过的(没出现过的数字的数量 = 重复数字的数量) Companies always have a lot of equipment, furniture and other things. All o 阅读全文
摘要:
Little Lesha loves listening to music via his smartphone. But the smartphone doesn't have much memory, so Lesha listens to his favorite songs in a wel 阅读全文
摘要:
You are given a string tt consisting of nn lowercase Latin letters and an integer number kk . Let's define a substring of some string ss with indices 阅读全文