"Sum Queries? CodeForces 1217E (线段树)" 题意: 定义一个集合为$balanced$的,当且仅当集合内数字之和的每个十进制位,都与集合中某个数该位相同。否则,称该集合为$unbalanced$的。 给定一个长度为$n$的序列,$q$次询问一个区间内数字之和最小的 $ ...
分类:
其他好文 时间:
2019-09-12 19:48:41
阅读次数:
80
题目链接 "题目链接 http://poj.org/problem?id=3274" 题意 输入每头牛的特征的10进制,若i~j头牛中每个数位的特征相等则满足要求,求所有满足要求的j i的最大值。 解题思路 1. 抽屉原理,用前缀和处理每个数位即可。 2. 直接暴力的话复杂度太大了,所以需要取巧的办 ...
分类:
其他好文 时间:
2019-09-07 13:08:41
阅读次数:
99
Parentheses 题目描述 Dave loves strings consisting only of '(' and ')'. Especially, he is interested in balanced strings. Any balanced strings can be cons ...
分类:
其他好文 时间:
2019-09-03 21:56:48
阅读次数:
62
题面 好题啊!~ 设f[i][j][k][l]表示已经处理完前i个请求后,a在j,b在k,c在l的最小值是多少; 那么f[i][p[i]][k][l]=min(f[i][p[i]][k][l],f[i-1][j][k][l]+c(j,p[i])); f[i][j][p[i]][l]=min(f[i] ...
分类:
其他好文 时间:
2019-09-03 16:56:06
阅读次数:
86
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced bina ...
分类:
其他好文 时间:
2019-09-02 10:01:14
阅读次数:
111
You are given a sequence A[1], A[2], ..., A[N] . ( |A[i]| ≤ 15007 , 1 ≤ N ≤ 50000 ). A query is defined as follows: Query(x,y) = Max { a[i]+a[i+1]+... ...
分类:
其他好文 时间:
2019-08-31 12:38:24
阅读次数:
69
Count on a tree SPOJ 主席树+LCA(树链剖分实现)(两种存图方式) 题外话,这是我第40篇随笔,纪念一下。 include include include using namespace std; const int maxn=1e5+100; struct node{ int ...
分类:
其他好文 时间:
2019-08-29 23:56:56
阅读次数:
225
题意:求树上A,B两点路径上第K小的数 AT ...
分类:
其他好文 时间:
2019-08-28 13:04:39
阅读次数:
70
思路 "题目链接" 题意 :题目中先给了一个N阶矩阵样子的字符,后给了一个mask,然后又给出你应该认识的一些单词,最后是让你输出最终字典序最小的一句话。 思路 :根据题目要求模拟即可。这里会用到stringstream,学习一下。不过个人觉得比较重要的是矩阵旋转部分,下面附这一块的代码。 c vo ...
分类:
其他好文 时间:
2019-08-18 13:49:57
阅读次数:
83
Question Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in whic ...
分类:
其他好文 时间:
2019-08-18 09:59:24
阅读次数:
100