UVaLive6039 Uva1668 Let's Go Green
一开始考虑所有边都是单独的一条路径
然后尽量多的合并
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream> using namespace std; void setIO(const string& s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
template<typename Q> Q read(Q& x) {
static char c, f;
for(f = ; c = getchar(), !isdigit(c); ) if(c == '-') f = ;
for(x = ; isdigit(c); c = getchar()) x = x * + c - '';
if(f) x = -x;
return x;
}
template<typename Q> Q read() {
static Q x; read(x); return x;
} const int N = + ;
int main() {
#ifdef DEBUG
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif static int du[N], mx[N];
int T = read<int>();
for(int cas = ; cas <= T; cas++) {
memset(du, , sizeof du);
memset(mx, , sizeof mx);
int ans = ;
int u, v, w, n = read<int>();
for(int i = ; i < n; i++) {
read(u), read(v), read(w);
du[u] += w, du[v] += w;
mx[u] = max(mx[u], w);
mx[v] = max(mx[v], w);
ans += w;
} for(int u = ; u <= n; u++) {
if((mx[u] << ) <= du[u]) ans -= du[u] >> ;
else ans -= du[u] - mx[u];
} printf("Case #%d: %d\n", cas, ans);
} return ;
}
UVaLive6039 Uva1668 Let's Go Green的更多相关文章
- 分形之概率学下的green tree
今天做的是分形之随机概率,可以和以前做的那个抛色子的做法非常相似,抛色子是用随机点数控制图形,今天做的树叶图形只是用概率的做法去控制图形而已,做法是如出一辙的: //图形界面 package ...
- python 安装nltk,使用(英文分词处理,词干化等)(Green VPN)
安装pip命令之后: sudo pip install -U pyyaml nltk import nltk nltk.download() 等待ing 目前访问不了,故使用Green VPN htt ...
- Eclipse UML插件Green UML、AmaterasUML
一.Green UML插件 1.查看Eclipse版本 查看当前电脑上安装的Eclipse版本(Help-About Eclipse Platform),是3.3.2版本的. 2.查看相应插件版本 然 ...
- elasticsearch 索引 red 状态恢复 green
方案一 找到状态为 red 的索引 curl -X GET "http://172.xxx.xxx.174:9288/_cat/indices?v=" red open index ...
- English - Green Peanut Butter
There is a guy. He wants to drink 12 cups of green peanut butter. He needs green peanut butter. So h ...
- [物理学与PDEs]第5章第2节 变形的描述, 应变张量 2.2 Cauchy - Green 应变张量
1. 引理 (极分解): 设 $|{\bf F}|\neq 0$, 则存在正交阵 ${\bf R}$ 及对称正定阵 ${\bf U},{\bf V}$ 使得 $$\bex {\bf F}={\bf ...
- ISP PIPLINE (附加1) Green Imbalance
1.什么是Green imbalance 芯片的Gr和Gb通道获取的能量或者是输出的数据不一致,造成这种情况的原因一方面是Gr,Gb通道的半导体制造工艺方面的差异,另一方面是microlens的存在, ...
- Derive representation formula from Green’s identity
This article introduces how to derive the representation formula used in BEM from Green's identity. ...
- 电影《Green book》观后感_已补全:携带着种族歧视的“光环”,艰难地获得朋友的相互依赖,依然得享受生活的酸甜苦咸。
目录 1.电影基本情况介绍 2.故事整个发展经历 3.观影感受 4.网友评论 <Green book>--绿皮书 作者总共看这部影片三次,第一次英文版慢看,第二次中文版快看,第三次中文版总 ...
随机推荐
- winform下mapxtreme2008 v7.0 生成release版提示找不到dll问题
在winform下基于mapxtreme2008 v7.0 生成了一个地图软件,用debug方式运行无误,但改为release版时提示缺少一大堆dll,如: 无法从C:\Program Files ( ...
- [Linux]Ubuntu下如何将普通用户提升到root权限
转至:http://jingyan.baidu.com/album/6181c3e0780131152ef153ff.html?picindex=0&qq-pf-to=pcqq.c2c 在u ...
- Linux进程和进程边界
1. 进程和线程 2. 手机操作系统的发展 3. 进程的地址空间边界 4. 进程边界的安全围栏: Crash的不可扩延性 5. 进程边界的安全围栏: 全局数据和服务的不可访问性 http://www. ...
- yii2的安装使用
一.Yii2框架 Yii2框架有基本和高级两种版本,主要区别是高级版已经分好了前台.后台,基本版只有前台 二.归档安装方法 归档安装方发很简单,只需要在官网上下载归档文件后,解压即可使用(但是不使用c ...
- ASP.NET MVC轻教程 Step By Step 12——客户端验证
前面两节使用的两种数据验证方法都是在服务器端进行的,也就是提交了表单,数据回传给服务器才能验证.这样会带来两个问题,一是用户体验不好,用户提交了表单之后才知道存在问题:二是会给服务器带来额外的压力.我 ...
- 局部视图(partial)
局部视图(partial) 原文:Partial Views作者:Steve Smith翻译:张海龙(jiechen).刘怡(AlexLEWIS)校对:许登洋(Seay).何镇汐.魏美娟(初见) AS ...
- FutureTask源码解读
import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.ut ...
- 领域驱动设计(Domain Driven Design)参考架构详解
摘要 本文将介绍领域驱动设计(Domain Driven Design)的官方参考架构,该架构分成了Interfaces.Applications和Domain三层以及包含各类基础设施的Infrast ...
- (转载)KL距离,Kullback-Leibler Divergence
转自:KL距离,Kullback-Leibler Divergence KL距离,是Kullback-Leibler差异(Kullback-Leibler Divergence)的简称,也叫做相对 ...
- python判断用户注册中用户名是否包含非法字符
class UserRegisterForm(ModelForm): role = forms.IntegerField() check_password = forms.CharField(requ ...