Description There is a robot, its task is to bury treasures in order on a N × M grids map, and each treasure can be represented by its weight, which is an integer. The robot begins to bury the treasures from the top-left grid. Because it is stupid, i…
Description There are n lotus leaves floating like a ring on the lake, which are numbered 0, 1, ..., n-1 respectively. The leaf 0 and n-1 are adjacent. The frog king wants to play a jumping game. He stands at the leaf 0 initially. For each move, he j…
Description Given a m × n chessboard, a stone is put on the top-left corner (1, 1). Kevin and Bob take turns moving the stone. One can only move the stone one block right or downward and cannot stay in the same block. Kevin goes first and the one who…
Description Given a string S, which consists of lowercase characters, you need to find the longest palindromic sub-string. A sub-string of a string S is another string S' that occurs "in" S. For example, "abst" is a sub-string of "…
Description Given n numbers, your task is to insert '+' or '-' in front of each number to construct expressions. Note that the position of numbers can be also changed. You can calculate a result for each expression. Please count the number of distinc…
Description Handoku is sailing on a lake at the North Pole. The lake can be considered as a two-dimensional square plane containing N × N blocks, which is shown in the form of string containing '*' and '#' on the map. : a normal block; : a block cont…
Description Corn does not participate the STEED contest, but he is interested in the word "STEED". So, Corn writes all permutations of the word "STEED" on different cards and gets 60 cards finally. Corn sorts these cards in lexicograph…
以下题目均自己搜 F题  A序列 一开始真的没懂题目什么意思,还以为是要连续的子串,结果发现时序列,简直智障,知道题意之后,好久没搞LIS,有点忘了,复习一波以后,直接双向LIS,处理处两个数组L和R,然后对整个数组扫一遍对于每一个下标取m=min(L[i],R[i]);用ans取2*m-1中的最大值.LIS用nlogn的算法实现,二分用的是lower_bound(),直接看代码. //Author: xiaowuga #include <bits/stdc++.h> #define maxx…
题目链接  2016 CCPC东北地区大学生程序设计竞赛 B题 题意  给定一个无向图和一棵树,树上的每个结点对应无向图中的一条边,现在给出$q$个询问, 每次选定树中的一个点集,然后真正被选上的是这些点以及这些点的所有祖先. 只有标号在树中真正被选上的点代表的这些原图中的边是存在的,这样就构成了一个新的图.求这个图的连通块个数. dfs整棵树,记$f[x]$为若$x$以及$x$的所有祖先被选上,那么构成的新的图的并查集) 这个实现比较简单,搜索的时候打上标记,回来的时候撤销即可. 这样预处理的…
黑白图像直方图 发布时间: 2017年7月9日 18:30   最后更新: 2017年7月10日 21:08   时间限制: 1000ms   内存限制: 128M 描述 在一个矩形的灰度图像上,每个像素点或者是黑色的或者是白色的.黑色像素点用1表示,白色像素点用0表示.现在要求你编写一个程序,计算每列上黑色像素点的个数并输出.如下图所示是一个6∗8的黑板图像. 1 1 0 0 1 1 1 1  0 1 1 0 1 0 1 0  1 1 1 1 0 1 1 0  0 1 1 0 0 1 0 0 …