Given an array of characters, compress it in-place. The length after compression must always be smaller than or equal to the original array. Every ele ...
分类:
其他好文 时间:
2020-01-12 13:42:25
阅读次数:
92
上代码: 1 //用结构和STL常用算法实现对学生成绩的排序和查找。 2 #include<iostream> 3 #include<vector> 4 #include<algorithm> 5 #include<cstring> 6 using namespace std; 7 8 struct ...
分类:
其他好文 时间:
2020-01-11 18:31:53
阅读次数:
101
贪婪算法 贪心算法(Greedy Algorithm) 简介贪心算法,又名贪婪法,是寻找最优解问题的常用方法,这种方法模式一般将求解过程分成若干个步骤,但每个步骤都应用贪心原则,选取当前状态下最好/最优的选择(局部最有利的选择),并以此希望最后堆叠出的结果也是最好/最优的解。{看着这个名字,贪心,贪 ...
分类:
编程语言 时间:
2020-01-11 18:12:53
阅读次数:
90
memset:按照字节填充字符 ①头文件:#include <string.h> ②一般用于填充char数组 ③用memset填充int数组的话,只能赋值0,-1,INF(0x3f3f3f3f),否则会出错,直接赋值为-1 fill:为一个区间赋值 ①头文件:#include <algorithm> ...
分类:
其他好文 时间:
2020-01-11 15:31:08
阅读次数:
93
题解:vector + 优先队列 -> 迪杰斯特拉算法 不必求任何两点的距离,只求行星据点到其余每个点的距离即可 把count个行星据点到其余每个点的距离存入二维数组 每一列就是对应顶点i到每个行星据点的最短距离,取出放入一维数组sort,然后取前k个即可,如果遇到INF则跳过不取 //迪杰斯特拉算 ...
分类:
其他好文 时间:
2020-01-11 14:52:50
阅读次数:
75
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; const int N=205; const int inf=21474800 ...
分类:
其他好文 时间:
2020-01-11 13:26:45
阅读次数:
77
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; const int N = 1e5 + 5; int a[N], tmp[N]; void merge_sort(int q[], int ...
分类:
编程语言 时间:
2020-01-10 22:21:25
阅读次数:
83
未优化的迪杰斯特拉:30分的代码 #include <stdio.h> #include <iostream> #include <queue> #include <string.h> #include <algorithm> #define MAX 10000 #define INF 999999 ...
分类:
其他好文 时间:
2020-01-10 22:12:00
阅读次数:
66
GitHub地址:https://github.com/hustcc/JS-Sorting-Algorithm 摘录一二: 1.冒泡排序 Python实现: def bubbleSort(arr): for i in range(1, len(arr)): for j in range(0, len ...
分类:
编程语言 时间:
2020-01-10 15:36:16
阅读次数:
69
数数题还是要多练啊 code: #include <cstdio> #include <cstring> #include <string> #include <vector> #include <algorithm> #define N 3004 #define ll long long #def ...
分类:
其他好文 时间:
2020-01-10 11:00:23
阅读次数:
79