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. Delphi 二维码生成

    Delphi 二维码生成 http://download.csdn.net/detail/warrially/7370171

  2. Jmeter 循环控制器 遍历结果

    1.测试计划,添加Mysql jar包 2.线程组 3.JDBC Connection Configuration,配置Mysql 4.添加JDBC Request,将查询出的数据对应的存入usern ...

  3. deepFreeze

    obj1 = {   internal: {} }; Object.freeze(obj1); obj1.internal.a = 'aValue'; obj1.internal.a // 'aVal ...

  4. Windows Server2003 关闭 关机信息、开机ctrl+alt+del

    取消CTRL+ALT+DEL win+R 或从"开始"打开"运行",输入gpedit.msc打开"组策略编辑器",依次展开"计算机 ...

  5. 清除mac中自动记录的git用户名和密码

    应用程序-实用工具-双击钥匙串-右上角搜索github-右击选项删除

  6. [Bzoj1008][HNOI2008]越狱(组合计数)

    题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1008 组合计数的简单题,可能越狱的方案数等于总方案数-不可能越狱的方案数,则: 总方案数 ...

  7. luoguP2590 [ZJOI2008]树的统计(树链剖分)

    luogu P2590 [ZJOI2008]树的统计 题目 #include<iostream> #include<cstdlib> #include<cstdio> ...

  8. 华为Android手机打开Log

    华为Android手机打开Log, 显示日志方法 今天在华为u8650上调试应用程序时,发现Eclipse的log始终无法显示,在网上找了好多资料,甚至stack overflow也查了,最后终于找到 ...

  9. springboot的jar包部署

    由于springboot常用war包部署,改为cloud开发模式多端口情况下,部署反而不习惯 毕竟,war包要不要项目名访问都必须放在tomcat的root目录下 而此目录限制只能放置一个项目,并且登 ...

  10. how to use epoll with python

    1 import socket, select 2 3 EOL1 = b'\n\n' 4 EOL2 = b'\n\r\n' 5 response = b'HTTP/1.0 200 OK\r\nDate ...