dfs暴力,也就是二进制枚举的思想,也就是枚举所有的情况,这个题目有个很好的剪枝,就是先排序,然后在 这样可以避免答案出现相同的组合。 code: class Solution { public: int p[1000]; vector<vector<int>> ans; vector<int> v ...
分类:
其他好文 时间:
2020-09-17 21:24:53
阅读次数:
42
stringint2binarystring(intiNumber,intiBits){vector<int>bTemp;for(intj=(iBits-1);j>=0;j--){bTemp.push_back((iNumber>>j)&1);}stringsBinary;for(intk=0;k<bTemp.size();k++){if(0==bTem
分类:
其他好文 时间:
2020-09-17 19:14:16
阅读次数:
22
push_back: 函数原型为: void push_back(const value_type& val); void push_back(value_type& val); 作用:在vector当前最后一个元素之后添加一个新元素,会调用拷贝函数或者移动构造函数。 // vector::push ...
分类:
其他好文 时间:
2020-09-17 18:10:49
阅读次数:
31
17. 电话号码的字母组合 排列题目,很容易想到回溯。下面是ac代码。 class Solution { private: vector<string> vstrs = {"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"}; public ...
分类:
其他好文 时间:
2020-09-17 17:29:41
阅读次数:
23
c++11提供了关键字noexcept,用来指明某个函数无法——或不打算——抛出异常: void foo() noexcept; // a function specified as will never throw void foo2() noexcept(true); // same as fo ...
分类:
编程语言 时间:
2020-09-17 17:07:05
阅读次数:
27
1 int main() { 2 vector<int> nums{ 5,4,2,6,7,3,9 }; 3 int length = nums.size(); 4 5 stack<vector<int>>sk1; 6 vector<int>rightFirstMax(length, 0); 7 fo ...
分类:
其他好文 时间:
2020-09-17 16:13:12
阅读次数:
18
由于是无向无权图,采用BFS 自环对于最短路无影响 重边和其它边对最短路径数的影响是一样的,不用做特别处理 采用dp思想即可统计出1号点到每个点的最短路径数 const int N=1e6+10; vector<int> g[N]; int dist[N]; bool vis[N]; int cnt ...
分类:
其他好文 时间:
2020-09-17 15:36:22
阅读次数:
25
https://github.com/januwA/GameCheat #include "pch.h" #include <iostream> #include <Windows.h> #include "GameCheat.h" using namespace std; void __stdca ...
分类:
编程语言 时间:
2020-09-17 15:31:59
阅读次数:
36
20行写完极其害怕 只能跑1e5的数据,那个1e6强制在线的开o2只有20pts QAQ 不用reserve也可以过,不过开了之后200ms的点只要130-140ms #include<bits/stdc++.h> using namespace std; #define ll long long ...
分类:
其他好文 时间:
2020-09-17 12:26:24
阅读次数:
24
摘要: 今天我们来学习 Golang 中的一个基本的数据结构 slice, 这个和 C++ 中的 vector 容器思想基本一致,是一个容量可变的数组,那我们就来看下它和 array 的区别和联系,并对其中的典型操作给出分析。 数据结构 // StringHeader is the runtime ...
分类:
其他好文 时间:
2020-09-17 12:02:07
阅读次数:
24