zoukankan      html  css  js  c++  java
  • URAL 1614. National Project “Trams” (图论大YY)

    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 2n 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(2n − 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 2n 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 n1 ≤ n ≤ 100.

    Output

    Output n lines describing tram routes. Each route is a sequence of integers in the range from 1 to 2n 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
  • 相关阅读:
    JQuery实现Ajax应用
    访问本地json文件因跨域导致的问题
    python_控制台输出带颜色的文字方法
    查询数据量大时,你会选择关联表查询还是循环中依个查询? up
    自己动手写SQL字符串分解函数Split up
    关于Access数据库执行Update语句后,不报错,但影响行数总是返回0的问题...... up
    TCP和UDP的区别
    Linxu系统下怎么安装vim编辑器
    网络编程 委托
    学习POS的数据包分析
  • 原文地址:https://www.cnblogs.com/jhcelue/p/7039836.html
Copyright © 2011-2022 走看看