博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【树染色】 Color a tree
阅读量:3959 次
发布时间:2019-05-24

本文共 830 字,大约阅读时间需要 2 分钟。

#include
#include
#include
#include
#define N 1010using namespace std;struct node{
double avg; int si,v,fa; bool exist;}nodes[N];int find_fa(int x){
int fa = nodes[x].fa; while(!nodes[fa].exist){
fa = nodes[fa].fa; } return fa;}int find_max(int r,int n){
int res; double mx = -1; for(int i=1;i<=n;i++){
if(i!=r&&nodes[i].exist&&nodes[i].avg>mx){
mx = nodes[i].avg; res = i; } } return res;}int main(){
struct node no; int n,r; scanf("%d %d",&n,&r); while(n!=0&&r!=0){
for(int i=1;i<=n;i++){
scanf("%d",&nodes[i].v); nodes[i].si = 1; nodes[i].avg = nodes[i].v; nodes[i].exist = true; } for(int i=1;i

转载地址:http://xllzi.baihongyu.com/

你可能感兴趣的文章
C++实现http下载 && 24点计算编码风格
查看>>
memcached了解使用和常用命令详解
查看>>
GDB调试各功能总结
查看>>
"undefined reference to" 多种可能出现的问题解决方法
查看>>
类结构定义
查看>>
Windows下关于多线程类 CSemaphore,CMutex,CCriticalSection,CEvent,信号量CSemaphore的使用介绍
查看>>
图像处理基本算法(汇总)以及实现
查看>>
C++编程获取本机网卡信息 本机IP 包括Windows和Linux
查看>>
C++连接CTP接口实现简单量化交易
查看>>
服务端使用c++实现websocket协议解析及通信
查看>>
C# string.Format使用说明
查看>>
Linux下安装Mysql数据库开发环境
查看>>
Linux用户及用户组添加和删除操作
查看>>
通用 Makefile 的编写方法以及多目录 makefile 写法
查看>>
C++的4种智能指针剖析使用
查看>>
RPC框架实现之容灾策略
查看>>
Docker私库
查看>>
hdu——1106排序(重定向)
查看>>
hdu——1556Color the ball(树状数组)
查看>>
hdu——1541Stars(树状数组)
查看>>