F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Rikka with Graph

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1058    Accepted Submission(s): 553


Problem Description
As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:

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?
 

Input
There are no more than 100 testcases.

For each testcase, the first line contains two numbers $n,m(2 \leq n \leq 100, 0 \leq m \leq 100)$.

Then $m$ lines follow. Each line contains two numbers $u,v(1 \leq u,v \leq n)$ , which means there is an edge between $u$ and $v$. There may be multiedges and self loops.
 

Output
For each testcase, print a single line contains two numbers: The length of the shortest path between vertice 1 and vertice $n$ and the number of the ways of adding this edge.
 

Sample Input
2 1 1 2
 

Sample Output
1 1
 

Hint
You can only add an edge between 1 and 2.
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-20 09:39:56, Gzip enabled