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 ...
 
随机推荐
- laravel数据库的创建和迁移
			
数据库建立及迁移 Laravel 5 把数据库配置的地方改到了 `learnlaravel5/.env`,打开这个文件,编辑下面四项,修改为正确的信息: ? 1 2 3 4 5 6 7 DB_HOST ...
 - Perl 和 Python 的比较 【转】
			
转自:http://blog.chinaunix.net/xmlrpc.php?r=blog/article&id=4662991&uid=608135 作为万年Perl 党表示最近开 ...
 - 怎么使用 Laravel 的服务容器来优化读写数据库中的 options关键词
			
其中我们可以最方便地利用的一个特性就是 Laravel 的服务容器了.在这里我不多赘述 Service Container 是个啥,想了解的可以自行搜索.不想了解的就只要大致知道它是个可以 绑定/取出 ...
 - OC基础数据类型-NSData
			
1.NSData,数据,当我们需要把一些信息写入到文件里或发送到网络上,我们需要把这些数据转换下,变成纯粹的0.1字符流 1 NSString * str = @"hello, world! ...
 - win7下80端口被(Pid=4)占用的解决方法
			
首先介绍一种网上普遍的方法,就是查找占据80端口的进程,然后关闭它就行了. 1.运行cmd,然后输入netstat -a -n -o,回车:2.查看开头几行包含0.0.0.0:80的那一行最后的pid ...
 - mysqlbinlog抽取二进制日志中某库某表的日志
			
1.先使用myqlbinlog命令把整个库的二进制日志抽取出来 mysqlbinlog --database=db_name mysql-bin.xxxxxx > db_name.sql 2.然 ...
 - C++中的类型重定义
			
发现重复定义是由于从两个不同的路径包含了同一个头文件而引起的,同事也建议从另外一个路径打开工程试试, 这才慢慢发现了原因.这个原因可能有些拗口,而事实上要出现这种错误也有些"曲折" ...
 - [团队项目2.0]软件改进分析MathAPP
			
软件改进分析 在此基础上,进行软件的改进. 首先,我们把这个软件理解成一个投入市场的.帮助小朋友进行算术运算练习的APP. 从质量保证的角度,有哪些需要改进的BUG? 从用户的角度(把自己当成小学生或 ...
 - YTU 2991: 链表节点逆置(线性表)
			
2991: 链表节点逆置(线性表) 时间限制: 1 Sec 内存限制: 128 MB 提交: 14 解决: 6 题目描述 设计一个算法,将一个带头节点的数据域依次为a1,a2,-,an(n> ...
 - 单链表操作B                                                       分类:            链表             2015-06-07 12:42    15人阅读    评论(0)    收藏
			
数据结构上机测试2-2:单链表操作B TimeLimit: 1000ms Memory limit: 65536K 题目描述 按照数据输入的相反顺序(逆位序)建立一个单链表,并将单链表中重复的元素删除 ...