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\) 全部去掉,也就是可以理解为第一个 \ ...
随机推荐
- 服务器搭建域控与SQL Server的AlwaysOn环境过程(二) 搭建客户端节点 服务器
1. 修改客户端服务器的计算机名,重启后,如果服务器属于克隆服务器,需要修改服务器SID,如果没有则调过这一步. 命令行方式:启动Windows2008进入系统后,打开“CMD窗口”并进入到" ...
- React 第三天
第三天 01:在组件中使用style行内对象并封装样式对象: CmtItem.jsx: import React from 'react' //第一层封装 将样式对象和UI结构分离 // const ...
- C语言数组和指针是不同的
有一个这样的错误: 在一个文件中定义:int mango[100]; 在另一个文件中声明:extern int *mango; 将会产生错误 定义和声明的区别: 在C中,任何对象都有且只有一个定义 ...
- 洛谷 P1169 [ZJOI2007]棋盘制作 (悬线法)
和玉蟾宫很像,条件改成不相等就行了. 悬线法题目 洛谷 P1169 p4147 p2701 p1387 #include<cstdio> #include<algorithm& ...
- Unity 制作安装程序和卸载程序
1.最简单的方式通过winrar制作 但是做出来的页面好low的感觉 参考链接:https://www.cnblogs.com/fetty/p/5185913.html 2.通过inno制作安装程序: ...
- Win7+VS2010:mysql 源代码编译与调试
win7+vs2010源代码编译mysql 近期因为在实习,工作重点在于一些数据库的开发,为了更好的理解数据库的实现机制.眼下萌生了要研究一下mysql数据库源代码的想法.那么好吧,说干就干.首先我们 ...
- maven的setting设置
maven的setting设置,settings.xml文件,多写了几个仓库的地址: <?xml version="1.0" encoding="UTF-8&quo ...
- duplicate报ORA-01017权限问题
duplicate报ORA-01017权限问题 环境: OS:RedHat EnterPrise Linux 5.8 x64 Cluster:Oracle Grid 11.2.0.4 Databa ...
- mysql-总结select各子句及其顺序
顺序:from->where ->group by->having ->order by
- Pocket英语语法---三、英语动词的特点是什么
Pocket英语语法---三.英语动词的特点是什么 一.总结 一句话总结:即表示时间(时态),又表示人数(单复数) 1.第十七讲,不定量表达法? 1.a few为肯定含义几个,few为否定含义没几个, ...