题库练习 Jamie and Interesting Graph
← 上一题 下一题 →

A11497 | Jamie and Interesting Graph

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Jamie has recently found undirected weighted graphs with the following properties very interesting:

- The graph is connected and contains exactly $n$ vertices and $m$ edges.
- All edge weights are integers and are in range $[1,10^{9}]$ inclusive.
- The length of shortest path from $1$ to $n$ is a prime number.
- The sum of edges' weights in the minimum spanning tree (MST) of the graph is a prime number.
- The graph contains no loops or multi-edges.

If you are not familiar with some terms from the statement you can find definitions of them in notes section.

Help Jamie construct any graph with given number of vertices and edges that is interesting!

输入格式

First line of input contains 2 integers $n$ , $m$ ![](/uploads/acgo/image/b7c67376dffb51a9_843107cd7ba5.jpeg) — the required number of vertices and edges.

输出格式

In the first line output 2 integers $sp$ , $mstw$ $(1<=sp,mstw<=10^{14})$ — the length of the shortest path and the sum of edges' weights in the minimum spanning tree.

In the next $m$ lines output the edges of the graph. In each line output 3 integers $u$ , $v$ , $w$ $(1<=u,v<=n,1<=w<=10^{9})$ describing the edge connecting $u$ and $v$ and having weight $w$ .

输入输出样例

输入 #1
4 4
输出 #1
7 7
1 2 3
2 3 2
3 4 2
2 4 4
输入 #2
5 4
输出 #2
7 13
1 2 2
1 3 4
1 4 3
4 5 4
C++ 编辑器
输入
输出