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\) 全部去掉,也就是可以理解为第一个 \ ...
随机推荐
- django 分组统计遇见的问题
在使用 django 的时候发现了一个坑 例如: In [54]: print(F.objects.all().values("age").annotate(fff=Count(& ...
- centos7 jumpserver 部署和使用手册(一)
测试推荐环境 CPU: 64位双核处理器 内存: 4G DDR3 数据库:mysql 版本大于等于 5.6 mariadb 版本大于等于 5.5.6 环境 系统: CentOS 7.2 IP: 192 ...
- Oralce 视图 view
Oracle视图 Oracle的数据库对象分为五种:表,视图,序列,索引和同义词. 视图是基于一个表或多个表或视图的逻辑表,本身不包含数据,通过它可以对表里面的数据进行查询和修改.视图基于的表称为基表 ...
- Vue内置指令
v-text 类型: string用法: 更新元素的 textContent.如果要更新部分的 textContent ,需要使用 {{ Mustache }} 插值. v-html 类型: stri ...
- Hibernate中如何完成持久化类和数据库映射文件
因为最近写项目需要要到,就在这里码码字,方便以后做一个参考,在这里,我通过的是myeclipse的反向工程来配置持久化类和数据的映射文件的. 1.打开myeclipse,打开数据库视图,对应的是Win ...
- Linux的硬链接、软连接与拷贝
Linux链接分两种,一种被称为硬链接(Hard Link),另一种被称为符号链接(Symbolic Link).硬链接:创建一个与原文件任何信息都相同的目标文件(文件名可能不同,自由设定).硬连接的 ...
- 【BZOJ 1196】[HNOI2006]公路修建问题
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 二分最后选的边中的最大值是多少. mid 则所有边权小于等于mid的边都可以用了. 那么我们要怎么选择呢? ->优先选择一级的 ...
- 国庆 day 1 下午
一道图论好题(graph) Time Limit:1000ms Memory Limit:128MB 题目描述 LYK有一张无向图G={V,E},这张无向图有n个点m条边组成.并且这是一张带权图, ...
- jquery easyui的使用
第一步下载jquery easyui 下载地址:http://www.jeasyui.com/download/index.php 第二步创建Java web项目 第三步导入相关的文件..文件夹结构 ...
- 【甘道夫】Sqoop1.99.3基础操作--导入Oracle的数据到HDFS
第一步:进入clientShell fulong@FBI008:~$ sqoop.sh client Sqoop home directory: /home/fulong/Sqoop/sqoop-1. ...