URAL 1614. National Project “Trams” (图论大YY)
1614. National Project “Trams”
Memory limit: 64 MB
the city's tram network.
it will be possible to go by tram from every tram stop to any other tram stop without any intermediate stops.
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
Output
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 |
Problem Source: The 12th Urals Collegiate Programing Championship, March 29, 2008
space=1&num=1614" target="_blank">Printable version
Submit solutionspace=1&num=1614">Discussion
(4)
space=1&num=1614&author=me" class="myac" style="padding-left:23px">My submissions
All submissions (1014) Allaccepted submissions (481)
space=1&num=1614">Solutions rating (383)
#include<cstdio>
#include<iostream>
#include<iostream>
#include<cstring>
using namespace std;
int path[110]; //构造一条形状同样的路径
int main()
{
int n;
while(~scanf("%d",&n))
{
int t=2*n+2,cnt=0,l=1;
//对称构造
while(cnt!=2*n)
{
path[++cnt]=((t-l)-1)%(2*n)+1;
path[++cnt]=++l;
}
//输出
for(int i=1;i<=n;i++)
for(int j=1;j<=2*n;j++)
{
printf("%d%c",(path[j]+i-2)%(2*n)+1,j==2*n? '\n':' ');
}
}
return 0;
}
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std; int N, M; int main() {
int i, j, k;
cin>>N;
M = N*2;
for (i = 0; i < N; ++i) {
int now = i;
printf("%d", now+1);
for (j = 1; j < M; ++j) {
now = (now+j)%M;
printf(" %d", now+1);
}
puts("");
}
return 0;
}
URAL 1614. National Project “Trams” (图论大YY)的更多相关文章
- URAL 1614. National Project “Trams” [ 构造 欧拉回路 ]
传送门 1614. National Project “Trams” Time limit: 0.5 secondMemory limit: 64 MB President has declared ...
- Ural 1158. Censored! 有限状态自动机+DP+大整数
Ural1158 看上去很困难的一道题. 原文地址 http://blog.csdn.net/prolightsfxjh/article/details/54729646 题意:给出n个不同的字符,用 ...
- UVA 12487 Midnight Cowboy(LCA+大YY)(好题)
题目pdf:http://acm.bnu.edu.cn/v3/external/124/12487.pdf 大致题意: 一棵树,一个人从A节点出发,等可能的选不论什么一条边走,有两个节点B,C求这个人 ...
- [CF1303B] National Project - 数学
Solution \(2a>n\),一次性结束,直接输出 \(n\) \(a \geq b\),那么一直修即可,直接输出 \(n\) 否则,\(a\) 占弱势,我们考虑用 \(a\) 修一半需要 ...
- Educational Codeforces Round 82 B. National Project
Your company was appointed to lay new asphalt on the highway of length nn. You know that every day y ...
- Android开发工具全面转向Android Studio(3)——AS project/module的目录结构(与Eclipse对比)
如果AS完全还没摸懂的,建议先看下Android开发工具全面转向Android Studio(2)——AS project/module的CRUD. 注:以下以Windows平台为标准,AS以目前最新 ...
- Educational Codeforces Round 82 (Rated for Div. 2) A-E代码(暂无记录题解)
A. Erasing Zeroes (模拟) #include<bits/stdc++.h> using namespace std; typedef long long ll; ; in ...
- [CF百场计划]#3 Educational Codeforces Round 82 (Rated for Div. 2)
A. Erasing Zeroes Description You are given a string \(s\). Each character is either 0 or 1. You wan ...
- 【题解】Educational Codeforces Round 82
比较菜只有 A ~ E A.Erasing Zeroes 题目描述: 原题面 题目分析: 使得所有的 \(1\) 连续也就是所有的 \(1\) 中间的 \(0\) 全部去掉,也就是可以理解为第一个 \ ...
随机推荐
- NOIp模拟赛三十一
持续降智 分数:100+0+0=100 C题subtask是假的,根本没有部分分中的情况...还我20分QAQ A:[BZOJ4444]国旗计划 B:[agc006f]blackout C:[arc0 ...
- js Date() 时间函数处理 关于 toLocaleDateString()
toLocaleDateString()方法的真正含义为「根据本地时间把Date对象的日期部分转换为字符串」,这意味着:在不同的浏览器或者服务器中,我们可能得到不同的字符串. 例如,将 Chrome ...
- CF451E Devu and Flowers (组合数学+容斥)
题目大意:给你$n$个箱子,每个箱子里有$a_{i}$个花,你最多取$s$个花,求所有取花的方案,$n<=20$,$s<=1e14$,$a_{i}<=1e12$ 容斥入门题目 把取花 ...
- autosar
AUTOSAR – RTE(1)基本概念 1. RTE概述 The Run-Time Environment (RTE) is at the heart of the AUTOSAR ECU arch ...
- 教你用webpack搭一个vue脚手架[超详细讲解和注释!]
1.适用人群 1.对webpack知识有一定了解但不熟悉的同学. 2.女同学!!!(233333....) 2.目的 在自己对webpack有进一步了解的同时,也希望能帮到一些刚接触webpack的同 ...
- vue+element-ui+slot-scope或原生实现可编辑表格(日历)
你们公司的产品是不是还在做一个可编辑表格功能? 1.前言 咱开发拿到需求大多数是去网上找成型的组件,找不到再看原生的方法能否实现,大牛除外哈,大牛一般喜欢封装组件框架. 2.思路 可编辑表格在后台管理 ...
- (50)与magento集成
我对接的是 odoo8 和 magento1.9.x 准备工作: l 服务器 装上mangento 组件 : $ pip install magento 装上 requests 组件:$ pip ...
- Java基础学习总结(45)——JAVA单元测试工具比较
1.简介 jtest是parasoft公司推出的一款针对java语言的自动化白盒测试工具,它通过自动实现java的单元测试和代码标准校验,来提高代码的可靠性.Jtest先分析每个java类,然后自动生 ...
- 009实现一个算法来删除单链表中的一个结点,仅仅给出指向那个结点的指针(keep it up)
呵呵,这个题不能直接删除已知的结点.由于是单链表,不知道前驱,仅仅知道 后继结点,直接删除会使链表断开.只是我们能够删除已知结点的后继结点, 把后继结点的值赋值给已知结点. #include < ...
- Android Camera+SurfaceView实现自己定义拍照
对Activity强制横屏,保证预览方向正确. 使用OrientationEventListener监听设备方向.推断竖拍时,旋转照片后再保存.保证竖拍时预览图片和保存后的图片方向一致. 执行效果: ...