URAL 1614. National Project “Trams” (图论大YY)

面对市长的要求,如何在一座拥有2n个电车站的城市中设计出n条满足市民出行需求的tram路线?每条路线需包含2n个站点,并且使得任意两站间都能直达。本文介绍了一种解决思路及具体的实现代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1614. National Project “Trams”

Time limit: 0.5 second
Memory limit: 64 MB
President has declared the development of tram service a priority national project. As a part of this project, Yekaterinburg will receive enough budget funds to carry out a complete reconstruction of the city's tram network.
There are 2 n tram stops in Yekaterinburg. In the course of reconstruction, the stops will be left in their places and no new stops will be built, but new tram railways will be laid so that it will be possible to go by tram from every tram stop to any other tram stop without any intermediate stops.
Having studied messages at the tram forum, the city authorities found out that citizens would be satisfied with the reconstruction only if for every pair of tram stops there would be a tram route connecting these stops without any intermediate stops. It is clear that the network of  n(2 n − 1) routes consisting of only two stops each satisfies this requirement. However, Yekaterinburg Mayor wants exactly  n routes to be left after the reconstruction, and each tram must make exactly 2 n stops (including the final ones) on its route. Trams must go along these routes in both directions. Suggest a plan of reconstruction that will satisfy both citizens and Mayor.

Input

The only input line contains the integer  n, 1 ≤  n ≤ 100.

Output

Output  n lines describing tram routes. Each route is a sequence of integers in the range from 1 to 2 n separated by a space. A route may go through a stop several times. If the problem has several solutions, you may output any of them. If there is no solution, output one line containing the number −1.

Sample

input output
3
1 6 2 1 3 4
2 3 6 5 4 6
5 1 4 2 5 3
Problem Author: Alexander Ipatov (idea — Magaz Asanov)
Problem Source: The 12th Urals Collegiate Programing Championship, March 29, 2008
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值