题目链接: D. Tree Construction D. Tree Construction time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output During the programming classes Vasya was assigned a difficult problem. However, he doesn't k…
[链接] 我是链接,点我呀:) [题意] 依次序将数字插入到排序二叉树当中 问你每个数字它的父亲节点上的数字是啥 [题解] 按次序处理每一个数字 对于数字x 找到最小的大于x的数字所在的位置i 显然,x要放在这个x的左子树里面 所以如果x的左子树为空那么直接放上去就好 否则,左子树不为空的话,对于i的左儿子,从这个左儿子开始,一直往右儿子方向往下走 即未插入x之前,最大的且比i对应的数字小的数字 less 我们的x显然是要放在less的右子树上才行. 这个less和位置i对应的数字都能用java…
codeforces Good bye 2016 E 线段树维护dp区间合并 题目大意:给你一个字符串,范围为‘0’~'9',定义一个ugly的串,即串中的子串不能有2016,但是一定要有2017,问,最少删除多少个字符,使得串中符合ugly串? 思路:定义dp(i, j),其中i=5,j=5,因为只需要删除2016当中其中一个即可,所以一共所需要删除的字符和需要的字符为20176,因此i和j只要5就够了. 然后转移就是dp(i,i) = 0, 如果说区间大小为1的话,那么如果是2017中的一个…
Dylans loves tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1444    Accepted Submission(s): 329 Problem Description Dylans is given a tree with N nodes. All nodes have a value A[i].Nodes…
BZOJ_2212_[Poi2011]Tree Rotations_线段树合并 Description Byteasar the gardener is growing a rare tree called Rotatus Informatikus. It has some interesting features: The tree consists of straight branches, bifurcations and leaves. The trunk stemming from t…
题目链接:http://codeforces.com/contest/620/problem/E E. New Year Tree time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output The New Year holidays are over, but Resha doesn't want to throw away the N…
题目链接 New Year Tree 考虑到$ck <= 60$,那么用位运算统计颜色种数 对于每个点,重新标号并算出他对应的进和出的时间,然后区间更新+查询. 用线段树来维护. #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i(a); i <= (b); ++i) struct node{ long long num, lazy; } tree[ << ]; st…
LINK 题目大意 给你一棵树 让你支持子树染色,子树查询颜色个数,颜色数<=60, 节点数<=4e5 思路 因为颜色数很少,考虑状态压缩变成二进制 然后直接在dfs序上用线段树维护就可以了 //Author: dream_maker #include<bits/stdc++.h> using namespace std; //---------------------------------------------- //typename typedef long long ll…
Flipping Parentheses 题目连接: http://codeforces.com/gym/100803/attachments Description A string consisting only of parentheses '(' and ')' is called balanced if it is one of the following. • A string "()" is balanced. • Concatenation of two balance…
D. Selection Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description When selecting files in an application dialog, Vasya noted that he can get the same selection in different ways. A simple mouse click selects a sing…