
--------emmm--------
Error Man
我是菜逼
展开
-
codeforces 1257F (折半 + 技巧 (Meet-in-the-middle))
F. Make Them Similar Let’s call two numbers similar if their binary representations contain the same number of digits equal to 1. For example: 2 and 4 are similar (binary representations are 10 and 10...原创 2019-11-18 11:06:47 · 378 阅读 · 0 评论 -
树上最长路(模版)
树上最长路其实很好写。只需要两边dfs。 第一遍从随意一个点dfs,找到最远距离的那一点。然后从那一个点进行 第二遍的dfs,最后求出来的max,就是树上的最长距离。 代码: int maxx = -1,maxid; void dfs(int p,int fa,int dep){ if(maxx < dep){ maxx = dep; ...原创 2018-08-18 22:28:30 · 450 阅读 · 0 评论 -
最长非下降子序列 nlogn + 记录路径
最长非下降子序列 #include <bits/stdc++.h> using namespace std; const int maxn = 100010; int p[maxn], tmp[maxn]; ///p[] 储存序列。tmp储存最长上升序列 int pos[maxn]; ///还原路径所用 int n; ///...原创 2018-08-31 11:56:21 · 582 阅读 · 0 评论