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-Day3
Moudle 1 Chapter 1 #练习题# 1.简述编译型与解释型语言的区别,且分别列出你知道的哪些语言属于编译型,哪些属于解释型?"""编译型:编译类指在应用源程 ...
- div隐藏但是依然占位置
<!doctype html> <html> <head> <meta charset="utf-8"> <script ty ...
- SKU和SPU表的设计
1.什么是SKU,SPU SKU:Stock Keeping Unit (库存量单位)SKU即库存进出计量的单位,可以是以件.盒.托盘等为单位,是物理上不可分割的最小存货单元.在使用时要根据不同业态, ...
- webpack 操作
依赖安装 : 全局安装webpack : sudo npm install webpack -g 本地安装webpack : npm install webpack —save-dev 需要注意的 ...
- UE4自学随笔(一)
本文及后续均为个人学习记录所用,难免毫无章法零零碎碎,希望看到此文的诸君勿怪. 一.Actor与Pawn Actor类 在UE4中,Actor类是可以放到游戏场景中的游戏对象的基本类型.你如果想放置任 ...
- HDU-4370 '0 or 1' 最短路 要考虑连通性
题目链接:https://cn.vjudge.net/problem/HDU-4370 题意 给一个矩阵C(nn),要我们找到一个矩阵X(nn),满足以下条件: X_{12}+X_{13}+...X_ ...
- 学习CV:《OpenCV 3计算机视觉Python语言实现第2版》中文PDF+英文PDF+代码
理解与计算机视觉相关的算法.模型以及OpenCV 3 API背后的基本概念,有助于开发现实世界中的各种应用程序(比如:安全和监视领域的工具). OpenCV 3是一种先进的计算机视觉库,可以用于各种图 ...
- vue-quill-editor-upload : 实现vue-quill-editor上传图片到服务器
vue-quill-editor-upload git: https://github.com/NextBoy/vu... A plug-in for uploading images to your ...
- Vue异步组件Demo
Vue异步组件Demo 在大型应用中,我们可能需要将应用拆分为多个小模块,按需从服务器下载.为了进一步简化,Vue.js 允许将组件定义为一个工厂函数,异步地解析组件的定义.Vue.js 只在组件需要 ...
- 洛谷——P2863 [USACO06JAN]牛的舞会The Cow Prom
https://www.luogu.org/problem/show?pid=2863#sub 题目描述 The N (2 <= N <= 10,000) cows are so exci ...