HDU 5422 Rikka with Graph
Rikka with Graph
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 182 Accepted Submission(s): 95
Yuta has a non-direct graph with n
vertices and m
edges. The length of each edge is 1. Now he wants to add exactly an edge which connects two different vertices and minimize the length of the shortest path between vertice 1 and vertice n
. Now he wants to know the minimal length of the shortest path and the number of the ways of adding this edge.
It is too difficult for Rikka. Can you help her?
For each testcase, the first line contains two numbers n,m(2≤n≤100,0≤m≤100)
.
Then m
lines follow. Each line contains two numbers u,v(1≤u,v≤n)
, which means there is an edge between u
and v
. There may be multiedges and self loops.
and the number of the ways of adding this edge.
#include<iostream>
#include<cstdio>
using namespace std; int main()
{
int m, n;
while(~scanf("%d%d", &n, &m))
{
int u, v;
int ok = ;
for(int i=; i<m; i++)
{
scanf("%d%d", &u, &v);
if((u==&&v==n)||(v==&&u==n))
ok = ;
}
if(!ok) printf("%d %d\n",, );
else printf("%d %d\n",, n*(n-)/);
}
return ;
}
HDU 5422 Rikka with Graph的更多相关文章
- hdu 5422 Rikka with Graph(简单题)
Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he ...
- HDU 5631 Rikka with Graph 暴力 并查集
Rikka with Graph 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5631 Description As we know, Rikka ...
- HDU 6090 Rikka with Graph
Rikka with Graph 思路: 官方题解: 代码: #include<bits/stdc++.h> using namespace std; #define ll long lo ...
- HDU 5424——Rikka with Graph II——————【哈密顿路径】
Rikka with Graph II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
- HDU 6090 Rikka with Graph —— 2017 Multi-University Training 5
Rikka with Graph Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- hdu 5424 Rikka with Graph II(dfs+哈密顿路径)
Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so h ...
- 2017ACM暑期多校联合训练 - Team 5 1006 HDU 5205 Rikka with Graph (找规律)
题目链接 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, s ...
- hdu 5424 Rikka with Graph II (BestCoder Round #53 (div.2))(哈密顿通路判断)
http://acm.hdu.edu.cn/showproblem.php?pid=5424 哈密顿通路:联通的图,访问每个顶点的路径且只访问一次 n个点n条边 n个顶点有n - 1条边,最后一条边的 ...
- HDU 5424 Rikka with Graph II
题目大意: 在 N 个点 N 条边组成的图中判断是否存在汉密尔顿路径. 思路:忽略重边与自回路,先判断是否连通,否则输出"NO",DFS搜索是否存在汉密尔顿路径. #include ...
随机推荐
- spring 事件(Application Event)
spring 事件为bean 与 bean之间传递消息.一个bean处理完了希望其余一个接着处理.这时我们就需要其余的一个bean监听当前bean所发送的事件. spring事件使用步骤如下: 1.先 ...
- Ubuntu检测磁盘是否挂载
Ubuntu默认不自动挂载磁盘. 只是学习Bash使用,需优化如使用 # file: mountAll.sh # include color support # a list of variables ...
- Mac OS finder : 显示和隐藏文件[夹] show and hide files or folders
Finder默认是不显示隐藏文件[夹]的,要显示出怎么办? 要显示的话,可以GUI(graphic user interface)和CLI(command line interface)两种方式 CL ...
- javaWeb 使用cookie显示商品浏览记录
package de.bvb.cookie; import java.io.IOException; import java.io.PrintWriter; import java.util.Date ...
- crontab 日志备份定时任务
-l选项,查看当前用户的所有定时任务: [xiluhua@vm-xiluhua][/home]$ crontab -l * * * * * /home/xiluhua/shell_script/log ...
- Caused by: javax.xml.bind.JAXBException: standardPremiumUpdateMessageDTO is not a valid property on
Caused by: javax.xml.bind.JAXBException: standardPremiumUpdateMessageDTO is not a valid property on ...
- Centos7下用命令下载jdk7及jboss-eap-6
计划在南非的一台云主机上搭建一个web环境,首先需要在云主机上搭建我们指定版本的JDK和JBOSS. 在云上搭特定版本的环境,软件包传输是一件十分艰巨的任务.我先后尝试了:公司电信专线.公司联通专线. ...
- Linux之Ganglia源码安装
一.Ganglia简介: Ganglia是UC Berkeley发起的一个开源集群监视项目,设计用于测量数以千计的节点.Ganglia的核心包含gmond.gmetad以及一个Web前端.主要是用来监 ...
- FIleReader无法解决编码问题
可把FileReader 用InputStreamReader(new FileInputStream(String fileptah),"utf-8")替代
- Dive into python学习笔记
http://woodpecker.org.cn/diveintopython/index.html 1.第一个程序odbchelper.py def buildConnectionString(pa ...