码迷,mamicode.com
首页 >  
搜索关键字:vector    ( 11651个结果
宁波多校(四) B题 七彩魔法树(线段树)
只需要用二进制来表示50个数,这样不会超过ll范围 之后按照dfs建树后建线段树维护 #include<iostream> #include<algorithm> #include<stack> #include<vector> #include<cstring> using namespace s ...
分类:其他好文   时间:2020-07-10 00:39:02    阅读次数:94
宁波多校(四) C石头划分(二分)
看到最小最大,显然是经典二分 因此只需要枚举最大距离进行check 如果能存在k组或以上能满足组间距离大于等于mid 那么就可以放大,否则缩小 #include<iostream> #include<algorithm> #include<stack> #include<vector> #inclu ...
分类:其他好文   时间:2020-07-10 00:22:13    阅读次数:70
Codeforces 1375H Set Merging (分块)
题目链接 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
leetcode-----66. 加一
链接: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 组合(Medium)
题目来源: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
C++求树子节点权重最大的和
#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
8.图的邻点不同颜色
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
YCH的模拟赛 T3
暴搜或者字典树,但是因为输出所有的方案而不是方案数,不管什么做法都逃不过输出,所以都差不多 sol1:记忆化搜索 当枚举方案时,f[i]表示已经把字符串的前i个字母都拼好的情况下有多少方案 考虑从第i+1个字符开始到j是一个给定的单词 如果有这样的j的话就可以转移 然后开一个vector把每一个状态 ...
分类:其他好文   时间:2020-07-08 15:33:26    阅读次数:40
【刷题-LeetCode】164 Maximum Gap
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)-7月8日
题目 面试题 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
11651条   上一页 1 ... 39 40 41 42 43 ... 1166 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!