Codeforces 490F. Treeland Tour 暴力+LIS】的更多相关文章

枚举根+dfs 它可以活 , 我不知道有什么解决的办法是积极的 ...... F. Treeland Tour time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output The "Road Accident" band is planning an unprecedented tour around Treeland. The…
题目链接 Treeland Tour 题目就是让你求树上LIS 先离散化,然后再线段树上操作.一些细节需要注意一下. #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i(a); i <= (b); ++i) #define dec(i, a, b) for (int i(a); i >= (b); --i) typedef long long LL; const int N =…
Treeland Tour 离散化之后, 每个节点维护上升链和下降链, 感觉复杂度有点高, 为啥跑这么快.. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair<LL, int> #define PII pair<int, int&g…
题目链接:点击打开链接 题意: 给定n个点的树. 以下n个数表示点权. 以下n-1行给出树. 找一条链,然后找出这条链中的点权组成的最长上升子序列. 求:最长上升子序列的长度. 思路: 首先是维护一条链然后求答案.可是假设直接树形dp(记录每一个点u,u往下递增和u往下递减的长度)会使序列是来回的,即递增和递减都在同一条链上. 枚举每一个点作为子序列的开头,然后维护一条链进行LIS的nlogn做法. import java.io.PrintWriter; import java.util.Arr…
F. Treeland Tour time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output The "Road Accident" band is planning an unprecedented tour around Treeland. The RA fans are looking forward to the eve…
链接 Codeforces 667D World Tour 题意 给你一个有向稀疏图,3000个点,5000条边. 问选出4个点A,B,C,D 使得 A-B, B-C, C-D 的最短路之和最大. 思路 枚举中间两个点,端点就是不与这三个点重复的最大的那个点来更新答案.因为是稀疏图,可以做n遍spfa来维护两两之间的最短路. 代码 #include <iostream> #include <cstdio> #include <vector> #include <s…
B. World Tour 题目连接: http://www.codeforces.com/contest/666/problem/B Description A famous sculptor Cicasso goes to a world tour! Well, it is not actually a world-wide. But not everyone should have the opportunity to see works of sculptor, shouldn't he…
D. World Tour   A famous sculptor Cicasso goes to a world tour! Well, it is not actually a world-wide. But not everyone should have the opportunity to see works of sculptor, shouldn't he? Otherwise there will be no any exclusivity. So Cicasso will en…
题目链接:http://codeforces.com/problemset/problem/724/B 题目大意: 给出N*M矩阵,对于该矩阵有两种操作: (保证,每行输入的数是 1-m 之间的数且不重复) 1.交换两列,对于整个矩阵只能操作一次 2.每行交换两个数. 交换后是否可以使每行都是1-m 数字递增. 解题思路: 1.得到矩阵后先判断,是否每行可以交换两个数可以得到递增的矩阵,如果可以则输出"YES". 2.暴力交换两列,交换两列后,判断每行是否可以交换两个数得到递增的矩阵,…
codeforces 897A Scarborough Fair 题目链接: http://codeforces.com/problemset/problem/897/A 思路: 暴力大法好 代码: #include <iostream> #include <stdio.h> #include <string.h> using namespace std; typedef long long ll; int n,m; string s; int main() { ios…