
排序
zzuli-dk
这个作者很懒,什么都没留下…
展开
-
uva 10305 拓扑排序
#include #include #include #define N 120using namespace std;const int inf = 0x3f3f3f3f;int n, m, t;int G[N][N], vis[N], topo[N];bool dfs(int u){ vis[u]=-1; for(int v = 1;vn;v++)原创 2016-09-16 20:49:22 · 281 阅读 · 0 评论 -
poj 1094 拓扑排序
参考了大神的代码。。偶实在太弱了 T_T #include #include #include #include using namespace std;const int MAXN = 27;int n, m;int G[MAXN][MAXN];//建立两点的出入关系int in[MAXN];//统计入度int q[MAXN];//记录排序结果原创 2017-03-04 10:37:36 · 218 阅读 · 0 评论 -
归并排序
假如我输入一个n=10, 10个数分别为下标为[0,9]2,4,3,5,6,15,11,13,12,10那么遍历下标区间的顺序为一颗树 [ 0, 9 ] / ...原创 2017-03-26 15:34:30 · 235 阅读 · 0 评论 -
LibreOJ β Round #4 A. 游戏 找逆序对
题目链接:游戏 题解链接#include <iostream>#include <cstring>#include <algorithm>#include <cstdio>#include <vector>#include <queue>using namespace std;typedef long long LL;const int MAXN=100005;char str[原创 2017-09-04 10:23:11 · 239 阅读 · 0 评论 -
hdu Reward 拓扑排序 + 分层
题意:一直读错题意了。每个人都要领工资, 这里把每个人看成一个点, 给出两个点a, b, a的工资要大于b的工资, 拿到最少工资的人是888, 求所有员工的工资和。 46ms#include <bits/stdc++.h>using namespace std;typedef long long LL;const int inf = 0x3f3f3f3f;const int MAXN =原创 2017-08-29 16:26:21 · 358 阅读 · 0 评论 -
51 nod 1065 最小正子段和 排序大法好
思路:对前缀和排序,求相邻前缀和差的最小值和每个前缀和的最小值。#include <bits/stdc++.h>using namespace std;typedef long long LL;const int inf = 0x3f3f3f3f;const int MAXN = 50005;struct node{ LL sum; int k; bool oper原创 2017-11-13 10:37:21 · 240 阅读 · 0 评论 -
堆排序
实现从小到大(从大到小)排序,建立大顶堆(小顶堆)建立大顶堆(小顶堆反之)的思路:1.建立初始堆。(将二叉堆调整成父节点大于其孩子节点,从数组最后一个元素(二叉树最下面最右边的节点)的父亲节点开始调整)2.每次将跟节点的值和数组最后一个元素(二叉树最下面最右边的节点)互换,舍弃最后一个元素(原来为大顶堆根节点,也就是数组最大的数放到了数组的最后)#include <iost...原创 2018-10-29 11:42:11 · 125 阅读 · 0 评论