#1235 : New Teaching Buildings

时间限制:2000ms
单点时限:2000ms
内存限制:256MB

描述

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)网络赛的更多相关文章

  1. ACM-ICPC国际大学生程序设计竞赛北京赛区(2015)网络赛 B Mission Impossible 6

    #1228 : Mission Impossible 6 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 You must have seen the very famou ...

  2. ACM-ICPC国际大学生程序设计竞赛北京赛区(2015)网络赛 Scores

    #1236 : Scores 时间限制:4000ms 单点时限:4000ms 内存限制:256MB 描述 Kyle is a student of Programming Monkey Element ...

  3. hihoCoder 1578 Visiting Peking University 【贪心】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛)

    #1578 : Visiting Peking University 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Ming is going to travel for ...

  4. ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛 A Simple Job

    描述 Institute of Computational Linguistics (ICL), Peking University is an interdisciplinary institute ...

  5. ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛 The Book List

    描述 The history of Peking University Library is as long as the history of Peking University. It was b ...

  6. hihoCoder 1389 Sewage Treatment 【二分+网络流+优化】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛)

    #1389 : Sewage Treatment 时间限制:2000ms 单点时限:2000ms 内存限制:256MB 描述 After years of suffering, people coul ...

  7. hihoCoder 1391 Countries 【预处理+排序+堆】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛)

    #1391 : Countries 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are two antagonistic countries, countr ...

  8. hihoCoder 1392 War Chess 【模拟】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛)

    #1392 : War Chess 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Rainbow loves to play kinds of War Chess gam ...

  9. ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛 题目9 : Minimum

    时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 You are given a list of integers a0, a1, …, a2^k-1. You need t ...

随机推荐

  1. idea maven package报错"不再支持源选项 5 请使用 6 或更高版本。不支持发行版本 5"

    解决办法: 1.确保java compile以及project和module的java字节码版本是所用的java版本:

  2. 第一个 Maven 应用程序

    概述 使用 Maven 创建一个 Java Web 应用程序 创建 Maven 项目 选择 File -> New -> Project... 选择 Maven 项目 填写项目信息 选择工 ...

  3. Java泛型机制

    泛型程序设计 1.泛型程序设计的起源? 泛型是JDK1.5增加的新特性. 2.使用泛型的好处? 使用泛型机制编写的代码比那些杂乱使用Object变量,然后再进行强制类型转换的代码具有更好的安全性和可读 ...

  4. 20201102gryz模拟赛解题报告

    简述我的苦逼做题经历 考的是NOIP2017day1原题, 开始看到小凯的疑惑时感觉特水,因为这题初中老师讲过, 很nice的秒切 T2发现是个大模拟,虽然字符串不太会用,但起码题意很好理解 边打代码 ...

  5. Azure Terraform(八)利用Azure DevOps 实现Infra资源和.NET CORE Web 应用程序的持续集成、持续部署

    一,引言 上一篇讲解到利用 Azure DevOps 将整个 Azure Web App,Azure Traffic Manager profile,Azure Storage Account,Azu ...

  6. 基于Koa2框架的项目搭建及实战开发

    Koa是基于 Node.js 平台的下一代 web 开发框架,由express原班人马打造,致力于成为一个更小.更富有表现力.更健壮的 Web 框架.使用 koa 编写 web 应用,通过组合不同的 ...

  7. 上海某小公司面试题:Java线程池来聊聊

    <对线面试官>系列目前已经连载11篇啦!进度是一周更新两篇,欢迎持续关注 [对线面试官]Java注解 [对线面试官]Java泛型 [对线面试官] Java NIO [对线面试官]Java反 ...

  8. Phoenix表和索引分区优化方法

    Phoenix表和索引分区,基本优化方法 优化方法 1. SALT_BUCKETS RowKey SALT_BUCKETS 分区 2. Pre-split RowKey分区 3. 分列族 4. 使用压 ...

  9. Spring Boot 两种多数据源配置:JdbcTemplate、Spring-data-jpa

    多数据源配置 JdbcTemplate支持 Spring-data-jpa支持 多数据源配置 创建一个Spring配置类,定义两个DataSource用来读取application.propertie ...

  10. Docker及其使用思维导图

    学习Docker的使用. 包括Docker的一些命令,Docker容器的使用,Docker镜像的使用,Docker容器连接等内容. 各种思维导图下载地址 Docker使用思维导图及各各种命令 Dock ...