只需要用二进制来表示50个数,这样不会超过ll范围 之后按照dfs建树后建线段树维护 #include<iostream> #include<algorithm> #include<stack> #include<vector> #include<cstring> using namespace s ...
分类:
其他好文 时间:
2020-07-10 00:39:02
阅读次数:
94
看到最小最大,显然是经典二分 因此只需要枚举最大距离进行check 如果能存在k组或以上能满足组间距离大于等于mid 那么就可以放大,否则缩小 #include<iostream> #include<algorithm> #include<stack> #include<vector> #inclu ...
分类:
其他好文 时间:
2020-07-10 00:22:13
阅读次数:
70
题目链接 https://codeforces.com/contest/1375/problem/H 题解 首先注意到 $2.2\times 10^6\approx 2n\sqrt q$,因此想到分块。 考虑对值域进行分块,每块内值域连续,位置保持相对不变,大小为 \(B\),分成 \(\frac{ ...
分类:
其他好文 时间:
2020-07-09 19:20:27
阅读次数:
85
链接:https://leetcode-cn.com/problems/plus-one/ 代码 class Solution { public: vector<int> plusOne(vector<int>& digits) { int t = 1; for (int i = digits.si ...
分类:
其他好文 时间:
2020-07-08 21:27:49
阅读次数:
43
题目来源:leetcode77 组合 题目描述: 给定两个整数 n 和 k,返回 1 ... n 中所有可能的 k 个数的组合。 示例: 输入: n = 4, k = 2 输出: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ] 解题思路: 回溯 class ...
分类:
其他好文 时间:
2020-07-08 20:15:32
阅读次数:
60
#include <iostream> #include <vector> using namespace std; int n; const int MaxN = 1e5; long long w[MaxN + 1]; long long ans; vector<int> g[MaxN + 1]; ...
分类:
编程语言 时间:
2020-07-08 20:01:38
阅读次数:
78
class Solution { public: vector<int> gardenNoAdj(int N, vector<vector<int>>& paths) { vector<int> G[N]; for (int i=0; i<paths.size(); i++){//建立邻接表 G[p ...
分类:
其他好文 时间:
2020-07-08 19:35:09
阅读次数:
62
暴搜或者字典树,但是因为输出所有的方案而不是方案数,不管什么做法都逃不过输出,所以都差不多 sol1:记忆化搜索 当枚举方案时,f[i]表示已经把字符串的前i个字母都拼好的情况下有多少方案 考虑从第i+1个字符开始到j是一个给定的单词 如果有这样的j的话就可以转移 然后开一个vector把每一个状态 ...
分类:
其他好文 时间:
2020-07-08 15:33:26
阅读次数:
40
Maximum Gap Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Return 0 if the array contains le ...
分类:
其他好文 时间:
2020-07-08 15:25:35
阅读次数:
52
题目 面试题 16.11. 跳水板(leetcode) 我的思路 数学方法,一共k+1种情况:使用shorter0次到k次。一个循环把i*shorter+(k-i)*longer,0<=i<=k算一遍即可。 我的实现 class Solution { public: vector<int> divi ...
分类:
其他好文 时间:
2020-07-08 10:24:19
阅读次数:
64