9 July

并查集

int fa[];
for (int i=1; i<=n; ++i) fa[i]=i; int f(int x){return fa[x]==x?x:fa[x]=f(fa[x]);}
void join(int x,int y) {x=f(x),y=f(y); f[x]=y;}

最小生成树

边从小到大添加,共 \(n-1\) 条。统计边权和。

P1195 口袋的天空:

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
using namespace std; int n, m, K, cnt, fa[1003], sum;
struct node{int x,y,w;
bool operator <(const node&a)const{return w>a.w;}
};
priority_queue<node> G; int fi(int x) {return fa[x]==x?x:fa[x]=fi(fa[x]); }
void join(int x,int y){fa[fi(x)]=fi(y);} int main() {
scanf("%d%d%d", &n, &m, &K);
while (m--) {
int a,b,c;scanf("%d%d%d", &a,&b,&c);
G.push((node){a,b,c});
}
for (int i=1; i<=n; ++i) fa[i]=i;cnt=n;
while (!G.empty()){
node a=G.top();G.pop();
if (fi(a.x)!=fi(a.y)) join(a.x,a.y),sum+=a.w,--cnt;
if (cnt==K)break;
}
if (cnt!=K) printf("No Answer\n");
else printf("%d\n", sum);
return 0;
}

13 July

Review

Review: 9-13 July的更多相关文章

  1. Image Processing and Analysis_15_Image Registration:a survey of image registration techniques——1992

    此主要讨论图像处理与分析.虽然计算机视觉部分的有些内容比如特 征提取等也可以归结到图像分析中来,但鉴于它们与计算机视觉的紧密联系,以 及它们的出处,没有把它们纳入到图像处理与分析中来.同样,这里面也有 ...

  2. RFC 8684---TCP Extensions for Multipath Operation with Multiple Addresses

    https://datatracker.ietf.org/doc/rfc8684/?include_text=1 TCP Extensions for Multipath Operation with ...

  3. [Z] 计算机类会议期刊根据引用数排名

    一位cornell的教授做的计算机类期刊会议依据Microsoft Research引用数的排名 link:http://www.cs.cornell.edu/andru/csconf.html Th ...

  4. Peer Code Reviews Made Easy with Eclipse Plug-In

    欢迎关注我的社交账号: 博客园地址: http://www.cnblogs.com/jiangxinnju/p/4781259.html GitHub地址: https://github.com/ji ...

  5. [转]Debugging the Mac OS X kernel with VMware and GDB

    Source: http://ho.ax/posts/2012/02/debugging-the-mac-os-x-kernel-with-vmware-and-gdb/ Source: http:/ ...

  6. MongoDB十二种最有效的模式设计【转】

    持续关注MongoDB博客(https://www.mongodb.com/blog)的同学一定会留意到,技术大牛Daniel Coupal 和 Ken W. Alger ,从 今年 2月17 号开始 ...

  7. LSC问题(不连续问题)

    转载:http://blog.csdn.net/v_JULY_v/article/details/6110269 本文是动态规划算法中,网上写得最好的一个之一.看完很容易理解.需要重点理解的部分,我会 ...

  8. [官网]Linux版本历史

    This is a list of links to every changelog. https://kernelnewbies.org/LinuxVersions 总结一下 2.6.x 存在了八年 ...

  9. 转 gerrit

    开发环境 https://blog.csdn.net/u013207966/article/details/79112740 先记录下我的开发环境以及要正确安装gerrit需要用到的工具: Redha ...

随机推荐

  1. python web自动化测试框架搭建(功能&接口)——接口用例实现

    测试用例基类: # coding=utf-8 import unittest import Logger log = Logger.Loger() class BaseCase(unittest.Te ...

  2. vue-过滤器(filter)

    1.全局过滤器(项目中所有的vue文件都可以使用) 1.1  直接注册全局过滤器 在main.js中注册: 在项目中使用; 前面的为时间,作为filter过滤器的第一个参数. 1.2 所有过滤器写在一 ...

  3. 同余dp

    先验知识: 余数的计算公式:c = a -⌊ a/b⌋ * b 其中,⌊ ⌋为向下取整运算符,向下取整运算称为Floor,用数学符号⌊ ⌋表示 题目: Consider an arbitrary se ...

  4. Bootstrap 学习笔记8 下拉菜单滚动监听

    代码部分: <nav class="navbar navbar-default"> <a href="#" class="navba ...

  5. VS代码自动补全功能

    VS代码自动补全功能 新建工程后,依次打开 工具>>代码段管理器>>选择C++>>点击 添加(A)...按钮 ,设置你的代码块的目录 复制以下代码并存为note.s ...

  6. Autoencoder基本操作及其Tensorflow实现

    最近几个月一直在和几个小伙伴做Deep Learning相关的事情.除了像tensorflow,gpu这些框架或工具之外,最大的收获是思路上的,Neural Network相当富余变化,发挥所想.根据 ...

  7. github编程类书籍

    https://github.com/justjavac/free-programming-books-zh_CN

  8. EasyUI:Cannot read property 'width' of null

    最近在使用EasyUI DataGrid来做前端的报表开发,遇到了这个报错: Uncaught TypeError: Cannot read property 'width' of null 在网上查 ...

  9. Jmeter-后置处理器(Json extractor)

    后置处理器-json extractor 概念:顾名思义,提取json响应的数据中提取数据: 步骤:sampler-后置处理器-jsonextractor 1.提取单个参数 1.Variable na ...

  10. [Linux] 020 RPM 包的命名原则与其依赖性

    1. RPM 包命名原则 例如:httpd-2.2.15-15.e16.centos.1.i686.rpm 字符 释义 httpd 软件包名 2.2.15 软件版本 15 软件发布的次数 e16.ce ...