ACM-ICPC国际大学生程序设计竞赛北京赛区(2015)网络赛
#1235 : New Teaching Buildings
描述
Thanks to the generous finance income, Programming Monkey Elementary School is going to build three new teaching buildings.
The school could be seen as a connected graph with n vertices and m edges, in which every vertex belongs to at most a single cycle(the one consists of a sequence of vertices starting and ending at the same vertex, with each two consecutive vertices in the sequence adjacent to each other in the graph and no repetitions of vertices other than the repetition of starting and ending vertex.). For the sake of students’ physical well-being, the principal decides to find the longest “Y shape road” in the school and build the three new buildings in its three ends. A “Y shape road” contains three simple roads in the graph, which begins from a same vertex and don’t have any common vertices except it. As we know, a simple road is a finite sequence of edges which connect a sequence of vertices which are all distinct from one another. The longest one is exactly the one contains the largest length of roads.
Can you help him?
输入
There are no more than 600 test cases, and most cases are very small.
The first line of the input contains an integer T which means the number of test cases.
The first line of each test case contains two integers, n, m, which are the number of vertices and the number of edges. All vertices are numbered from 1 to n.
The next m lines, each line consists of three integers, u, v, w, which means there is an undirected edge between u and v, and its length is w.
Please note that n ≤ 100,000,w ≤ 1000
输出
For each test case, output the length of the largest “Y shape road”.
- 样例输入
-
2
5 5
1 2 9
5 1 2
2 5 3
3 4 6
3 1 2
3 3
1 2 1
2 3 3
3 1 2 - 样例输出
-
19
0
ACM-ICPC国际大学生程序设计竞赛北京赛区(2015)网络赛的更多相关文章
- ACM-ICPC国际大学生程序设计竞赛北京赛区(2015)网络赛 B Mission Impossible 6
#1228 : Mission Impossible 6 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 You must have seen the very famou ...
- ACM-ICPC国际大学生程序设计竞赛北京赛区(2015)网络赛 Scores
#1236 : Scores 时间限制:4000ms 单点时限:4000ms 内存限制:256MB 描述 Kyle is a student of Programming Monkey Element ...
- hihoCoder 1578 Visiting Peking University 【贪心】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛)
#1578 : Visiting Peking University 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Ming is going to travel for ...
- ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛 A Simple Job
描述 Institute of Computational Linguistics (ICL), Peking University is an interdisciplinary institute ...
- ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛 The Book List
描述 The history of Peking University Library is as long as the history of Peking University. It was b ...
- hihoCoder 1389 Sewage Treatment 【二分+网络流+优化】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛)
#1389 : Sewage Treatment 时间限制:2000ms 单点时限:2000ms 内存限制:256MB 描述 After years of suffering, people coul ...
- hihoCoder 1391 Countries 【预处理+排序+堆】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛)
#1391 : Countries 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are two antagonistic countries, countr ...
- hihoCoder 1392 War Chess 【模拟】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛)
#1392 : War Chess 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Rainbow loves to play kinds of War Chess gam ...
- ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛 题目9 : Minimum
时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 You are given a list of integers a0, a1, …, a2^k-1. You need t ...
随机推荐
- 使用remix实现给合约账户转账
实现内容:从remix上的虚拟账户上转账给自己编写的智能合约账户 前提基础:对solidity有一些基础了解,对以太坊的账户机制有一定了解. 账户 在以太坊中账户的唯一标识是地址(address). ...
- 解决Spirng注入时名称下的红色波浪线
解决Spirng注入时名称下的红色波浪线 报错情形: 解决办法: 方案一: 如果可以正常运行,那么可能是类没有交给Spring管理,如下图,我们只需要在对应的接口(或者类上)加上@Component注 ...
- 一体化的Linux系统性能和使用活动监控工具–Sysstat
[转]原文出处: Tecmint-Kuldeep Sharma 译文出处:Linux Story-天寒 欢迎分享原创到伯乐头条 在监控系统资源.系统性能和使用活动方面,Sysstat的确是一个 ...
- IDEA 简介
什么是IDEA IDEA 全称 IntelliJ IDEA,是 Java 语言开发的集成环境,IntelliJ 在业界被公认为最好的 Java 开发工具之一,尤其在智能代码助手.代码自动提示.重构.J ...
- threading.RLock()
# Copyright 2001-2017 by Vinay Sajip. All Rights Reserved.## Permission to use, copy, modify, and di ...
- 深入理解SPI机制-服务发现机制
https://www.jianshu.com/p/3a3edbcd8f24 SPI ,全称为 Service Provider Interface,是一种服务发现机制.它通过在ClassPath路径 ...
- LOJ10075 农场派对
USACO 2007 Feb. Silver N(1≤N≤1000) 头牛要去参加一场在编号为 x(1≤x≤N) 的牛的农场举行的派对.有 M(1≤M≤100000) 条有向道路,每条路长Ti(1≤ ...
- 利用Javascript制作网页特效(其他常见特效)
设置为首页和加入收藏夹 ①:在body标签内输入以下代码: <a onclick="this.style.behavior='url(#default#homepage)'; this ...
- CAS客户端和服务器配置https证书
关于如何生成https证书可以看这篇文章: java生成Https证书,及证书导入的步骤和过程 下面整理cas如何整合https: cas服务器端部署(TLS[https]) 1.生成证书: 参照ja ...
- (12)Linux文件系统层次结构
在 Linux 操作系统中,所有的文件和目录都被组织成以一个根节点"/"开始的倒置的树状结构 文件系统的最顶层是由根目录开始的,系统使用"/"来表示根目录,在根 ...