码迷,mamicode.com
首页 >  
搜索关键字:father    ( 584个结果
ZOJ4109 Welcome Party
并查集算连通块的数量,集合的个数就是必然不开心的人数,再跑bfs,用优先队列维护~ #include<bits/stdc++.h> using namespace std; const int maxn=1e6+14; vector<int> g[maxn]; int father[maxn]; i ...
分类:其他好文   时间:2020-02-13 19:20:12    阅读次数:48
PAT A1034 Head Of Gang
用并查集分割团伙,判断输出~ #include<bits/stdc++.h> using namespace std; const int maxn=10010; int father[maxn],isRoot[maxn]={0},weight[maxn]; unordered_map<string ...
分类:其他好文   时间:2020-02-13 00:04:46    阅读次数:54
定时弹出广告(图片)
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <link rel="stylesheet" type="text/css" href="21.css" /> <style> #father{ width:13 ...
分类:其他好文   时间:2020-02-04 16:03:05    阅读次数:87
《英诗金库》I-46:Full Fathom Five, by W. Shakespeare
作品基本信息作品名称:A Sea Dirge(海的挽歌)作者:William Shakespeare(威廉·莎士比亚)出版年代:1612编注:此诗选自《暴风雨》第一幕第二场。标题《海的挽歌》系原编者所加。作品原文Full fathom five thy father lies:Of his bone... ...
分类:其他好文   时间:2020-02-02 12:08:01    阅读次数:144
并查集——A1107.Social Clusters(30)
#include <bits/stdc++.h> #include <stdio.h> #include <stdlib.h> #include <queue> using namespace std; const int N = 1010; int father[N]; int isRoot[N] ...
分类:其他好文   时间:2020-02-01 00:34:08    阅读次数:51
并查集模板
const int N=120; int father[N]; int rank1[N]; void init(int Size) { for(int i=1;i<=Size;++i) father[i]=i,rank1[i]=0; } int Find(int x) { while(x!=fath ...
分类:其他好文   时间:2020-01-23 19:56:58    阅读次数:58
无根树转有根树
std::vector<int> tree[maxn]; int fa[maxn]; void dfs(int u,int father) { int len = tree[u].size(); for (int i = 0;i < len;i++) { int v = tree[u][i]; if ...
分类:其他好文   时间:2020-01-22 14:26:30    阅读次数:46
js继承模式
1、传统形式 > 原型链 过多的继承了没用的属性 Grand.prototype.lastName = "1"; function Grand(){ } var grand = new Grand(); Father.prototype = grand; function Father() { } ...
分类:Web程序   时间:2020-01-20 20:40:18    阅读次数:110
并查集的非递归路径压缩
我们知道,递归版路径压缩的实质就是在回溯过程中把沿途出现的爸爸变成兄弟,最终由N代同堂变成二代同堂。 所以我们可以利用这样的方法写出非递归路径压缩。 首先要找到根节点root,然后从当前位置出发寻找根节点,沿途得到的父亲节点father全部直接指向根节点。 如何得到沿途的父节点呢?当然是迭代啦! 1 ...
分类:其他好文   时间:2020-01-17 22:51:26    阅读次数:104
并查集
并查集:find() + union()+ init() 寻找根节点 + 合并子树 + 初始化 #include <stdio.h> #define MAX 100 using namespace std; int father[MAX]; //自己的父亲 int rank[MAX]; //秩 in ...
分类:其他好文   时间:2020-01-14 23:37:34    阅读次数:95
584条   上一页 1 ... 5 6 7 8 9 ... 59 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!