【构造】Gym - 100781B - Bell Ringing
根据n-1推n的情况,让n从每一个的最右走到最左,再从下一个最左走到最右,如此往复即可。
#include<cstdio>
using namespace std;
int n,a[50000][10],e,b[50000][10],e2;
int main(){
scanf("%d",&n);
if(n==1){
puts("1");
return 0;
}
e=1;
a[1][1]=1;
for(int i=2;i<=n;++i){
e2=0;
for(int j=1;j<=e;++j){
if(j%2==1){
for(int k=i;k>=1;--k){
int cnt=0;
++e2;
if(k==1){
++cnt;
b[e2][cnt]=i;
if(i==n)printf("%d%c",b[e2][cnt],cnt==i?'\n':' ');
}
for(int l=1;l<i;++l){
++cnt;
b[e2][cnt]=a[j][l];
if(i==n)printf("%d%c",b[e2][cnt],cnt==i?'\n':' ');
if(l==k-1){
++cnt;
b[e2][cnt]=i;
if(i==n)printf("%d%c",b[e2][cnt],cnt==i?'\n':' ');
}
}
}
}
else{
for(int k=1;k<=i;++k){
int cnt=0;
++e2;
if(k==1){
++cnt;
b[e2][cnt]=i;
if(i==n)printf("%d%c",b[e2][cnt],cnt==i?'\n':' ');
}
for(int l=1;l<i;++l){
++cnt;
b[e2][cnt]=a[j][l];
if(i==n)printf("%d%c",b[e2][cnt],cnt==i?'\n':' ');
if(l==k-1){
++cnt;
b[e2][cnt]=i;
if(i==n)printf("%d%c",b[e2][cnt],cnt==i?'\n':' ');
}
}
}
}
}
e=e2;
for(int j=1;j<=e2;++j){
for(int k=1;k<=i;++k){
a[j][k]=b[j][k];
}
}
}
return 0;
}
【构造】Gym - 100781B - Bell Ringing的更多相关文章
- Nordic Collegiate Programming Contest 2015 B. Bell Ringing
Method ringing is used to ring bells in churches, particularly in England. Suppose there are 6 bells ...
- 排序构造 GYM 101149 F - The Weakest Sith
题目链接:http://codeforces.com/gym/101149/my 题目大意:给你n个人,他们有成绩a,b,c.一个人如果两门课比另外一个人高,那么这个人就比那个人厉害.问,是否存在一个 ...
- Nordic Collegiate Programming Contest 2015(第七场)
A:Adjoin the Networks One day your boss explains to you that he has a bunch of computer networks tha ...
- Codeforces Gym 100187K K. Perpetuum Mobile 构造
K. Perpetuum Mobile Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/pro ...
- Codeforces Gym 100342H Problem H. Hard Test 构造题,卡迪杰斯特拉
Problem H. Hard TestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...
- Codeforces Gym 100531I Instruction 构造
Problem I. Instruction 题目连接: http://codeforces.com/gym/100531/attachments Description Ingrid is a he ...
- Codeforces Gym 100610 Problem A. Alien Communication Masterclass 构造
Problem A. Alien Communication Masterclass Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codefo ...
- Codeforces Gym 100425H H - Football Bets 构造
H - Football BetsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...
- Tree Reconstruction Gym - 101911G(构造)
---恢复内容开始--- Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given ea ...
随机推荐
- RelativeLayout相对布局中属性值
android:layout_above="@id/xxx" --将控件置于给定ID控件之上 android:layout_below="@id/xxx" ...
- js中的true和false
1.false undefined.NaN.0.null和空字符串''均被视为false 2.true 除上述以外的其它情况一律被视作true
- js 实时显示字数
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 【EverydaySport】健身笔记——动态牵拉
动态牵拉,包含了动态和牵拉两个概念.动态牵拉要求牵拉的过程要伴随着走路,即行进中牵拉,动态牵拉不仅可以使得肌肉得到延展,还可以激活肌肉协同工作,发展协调性.灵活性.进行动态牵拉时每个动作要进行5~10 ...
- linux驱动基础系列--Linux mmc sd sdio驱动分析
前言 主要是想对Linux mmc子系统(包含mmc sd sdio)驱动框架有一个整体的把控,因此会忽略某些细节,同时里面涉及到的一些驱动基础,比如平台驱动.块设备驱动.设备模型等也不进行详细说明原 ...
- EasyHook远程进程注入并hook api的实现
EasyHook远程进程注入并hook api的实现 http://blog.csdn.net/v6543210/article/details/44276155
- .net爬虫了解一下
using System; //添加selenium的引用 using OpenQA.Selenium.PhantomJS; using OpenQA.Selenium.Chrome; using O ...
- C高级 框架开发中红黑树结构
引言 -- 红黑树历史 红黑树是数据结构学习中一道卡. 底层库容器中必不可少的算法. 历经各种实战运用,性能有保障. 同样红黑树不好理解, 就算理解了, 代码也不好写. 就算写了, 工程库也难构建. ...
- 苹果电脑Mac OS系统重装图文详解
苹果电脑Mac OS系统重装图文详解 本文来自于[系统之家] www.xp85.com现在电脑都很强大,可是也很脆弱,常常需要你去维护,甚至经常需要你重装系统,那么Mac OS又如何重装系统呢?刚刚使 ...
- C#ActiveX控件开发
1.新建项目,选择C#,选择.NET Framework2.0,新建一个Windows窗体控件库项目,命名为ActiveXDemo; 2.右击ActiveXDem项目,选择属性——应用程序——程序集信 ...