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\) 全部去掉,也就是可以理解为第一个 \ ...
随机推荐
- python yield 生成器的介绍(转载)
您可能听说过,带有 yield 的函数在 Python 中被称之为 generator(生成器),何谓 generator ? 我们先抛开 generator,以一个常见的编程题目来展示 yield ...
- Javascript系列——对象元素的数组去重实现
概要 这是一篇记录文,记录数组操作对象去重的实现. 需求 有这样一个数组 [{ _id: 123, name: '张三' },{ _id: 124, name: '李四' },{ _id: 123, ...
- Visual Studio 2013 无法创建MVC项目,系统找不到指定的文件.(Exception from HRESULT:08x0070002)
在Visual Studio 2013中创建新MVC项目,(PS:现在创建个MVC项目,差点都找不到在哪,汗!-) 确定后提示,系统找不到指定的文件.(Exception from HRESULT:0 ...
- 仿百度排列图片预览插件-Simple Lightbox
很久以前遇到过这样的一个面试题,要求手写代码,实现百度图片的排列预览,并且可以左右点击查看下一张照片,当时没有做出来,这个问题也就一直放在了脑后,工作之后,遇到这样的需求之后,第一反应想到的是在源码网 ...
- 【codeforces 348B】Apple Tree
[题目链接]:http://codeforces.com/problemset/problem/348/B [题意] 给你一棵树; 叶子节点有权值; 对于非叶子节点: 它的权值是以这个节点为根的子树上 ...
- Linux split 命令用法详解 - 切割文件[转]
功能说明:切割文件.语 法:split [--help][--version][-<行数>][-b <字节>][-C <字节>][-l <行数>][要切 ...
- 我是怎么利用微信做兼职月入1W的
物价上涨.导致非常多人都感觉如今的收入入不敷出,有的是迫于生活压力.有的是为了提高生活质量,等等都想好好利用业余时间来做点兼职,当然我也不例外.正好笔者在微信刚推出一段时间的时候利用微信来做点兼职赚点 ...
- linux系统调用表(system call table)
系统调用号 函数名 入口点 源码 0 read sys_read fs/read_write.c 1 write sys_write fs/read_write.c 2 open sys_open f ...
- echarts 地图 动态 展示 结合css+js
echarts地图展示功能非常强大,官网上静态展示的样例非常多了,动态的资料少.研究了下.我眼下实现的通过ajax从server获取数据动态展示地图. 另外,我们有时候希望在地图之上做些自己定义的东西 ...
- so near yet so far
Dear little yang So beautiful boy as you, the most beautiful boy is you who i ever saw, like a sun , ...