Codeforces Round #279 (Div. 2)f
树形最大上升子序列
这里面的上生子序列logn的地方能当模板使 good
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
const int maxa = ;
vector<int>e[maxa];
int d[maxa];
int a[maxa];
int mx, n;
void dfs(int q, int p){
int k = lower_bound(d, d+n, a[q]) - d;
mx = max(mx, k);
int t = d[k];
d[k] = a[q];
for(int i = ; i < e[q].size(); i++){
if(e[q][i]!=p)
dfs(e[q][i], q);
}
d[k] = t;
}
int main(){
cin>>n;
for(int i = ; i <= n; i++)scanf("%d", a+i);
for(int i = ; i < n; i++){int x, y;
scanf("%d%d", &x, &y);
e[x].push_back(y);
e[y].push_back(x);
}
for(int i =; i <= n; i++)d[i] = (<<);
for(int i = ; i <= n; i++){
dfs(i, );
}printf("%d\n", mx+);
}
Codeforces Round #279 (Div. 2)f的更多相关文章
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #485 (Div. 2) F. AND Graph
Codeforces Round #485 (Div. 2) F. AND Graph 题目连接: http://codeforces.com/contest/987/problem/F Descri ...
- Codeforces Round #486 (Div. 3) F. Rain and Umbrellas
Codeforces Round #486 (Div. 3) F. Rain and Umbrellas 题目连接: http://codeforces.com/group/T0ITBvoeEx/co ...
- Codeforces Round #501 (Div. 3) F. Bracket Substring
题目链接 Codeforces Round #501 (Div. 3) F. Bracket Substring 题解 官方题解 http://codeforces.com/blog/entry/60 ...
- Codeforces Round #499 (Div. 1) F. Tree
Codeforces Round #499 (Div. 1) F. Tree 题目链接 \(\rm CodeForces\):https://codeforces.com/contest/1010/p ...
- Codeforces Round #376 (Div. 2)F. Video Cards(前缀和)
题目链接:http://codeforces.com/contest/731/problem/F 题意:有n个数,从里面选出来一个作为第一个,然后剩下的数要满足是这个数的倍数,如果不是,只能减小为他的 ...
- Codeforces Round #271 (Div. 2) F. Ant colony (RMQ or 线段树)
题目链接:http://codeforces.com/contest/474/problem/F 题意简而言之就是问你区间l到r之间有多少个数能整除区间内除了这个数的其他的数,然后区间长度减去数的个数 ...
- Codeforces Round #325 (Div. 2) F. Lizard Era: Beginning meet in the mid
F. Lizard Era: Beginning Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...
- Codeforces Round #271 (Div. 2) F题 Ant colony(线段树)
题目地址:http://codeforces.com/contest/474/problem/F 由题意可知,最后能够留下来的一定是区间最小gcd. 那就转化成了该区间内与区间最小gcd数相等的个数. ...
随机推荐
- express4.x中的链式路由句柄
var express = require("express"); var router = express(); router.get('/', function (req, r ...
- java 批量插入10万条数据
for (int i = 0; i < 100000; i++) { dbHelper.insert("INSERT aaa(name) Values ('1')"); } ...
- ural 1348 Goat in the Garden 2
http://acm.timus.ru/problem.aspx?space=1&num=1348 #include <cstdio> #include <cstring&g ...
- Altium Designer 画"差分线"
如何在 Altium Designer 中快速进行差分对走线1:在原理图中让一对网络前缀相同,后缀分别为_N 和_P,并且加上差分队对指示. 让一对差分网络名称的前缀必须相同,后缀分别为_N 和 ...
- Altium Designer中使用差分对布线
Contents Language 在原理图中定义差分对 在PCB中查看和管理差分对 在PCB中定义差分对 适用的设计规则 设置设计规则的辖域 使用差分对向导定义规则 差分对布线 包括管脚交换的FPG ...
- COJ WZJ的数据结构(负十八)splay_tree的天堂
WZJ的数据结构(负十八) 难度级别:E: 运行时间限制:100000ms: 运行空间限制:700KB: 代码长度限制:2000000B 试题描述 对于前一段样例: 输入 输入文件的第1行包含两个数N ...
- js执行引擎(js解释器)
看字面理解,js执行引擎讲的就是将js代码转化为机器码并执行的过程. 一款 JavaScript 引擎是由 Brendan Eich 在网景的 Navigator 中开发的,它的名字叫做 Spider ...
- java基础知识(一)
基本特征:封装性,继承性,多态性 一些新特征: 静态导入:import static 包名 可变参数的函数:add(int -x) 增强版for循环: for(int x:xs) 自动拆箱: 基本类型 ...
- 文件上传插件Uploadify在Struts2中的应用,完整详细实例
—>最近由于项目需要使用到一个上传插件,在网上发现uploadify挺不错,所以决定使用它,但是官网文档和例子是php的,而项目是SSI框架的,所以自己对uploadify在struts2中的使 ...
- OC基础:block.字面量
block 块语法,能够用block去保存一段代码,或者封装一段代码. block 实际是由c语言实现的,运行效率非常高. block 实际借鉴了函数指针的语法. block (^)(參数类型1 參数 ...