根据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的更多相关文章

  1. 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 ...

  2. 排序构造 GYM 101149 F - The Weakest Sith

    题目链接:http://codeforces.com/gym/101149/my 题目大意:给你n个人,他们有成绩a,b,c.一个人如果两门课比另外一个人高,那么这个人就比那个人厉害.问,是否存在一个 ...

  3. 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 ...

  4. Codeforces Gym 100187K K. Perpetuum Mobile 构造

    K. Perpetuum Mobile Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/pro ...

  5. Codeforces Gym 100342H Problem H. Hard Test 构造题,卡迪杰斯特拉

    Problem H. Hard TestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...

  6. Codeforces Gym 100531I Instruction 构造

    Problem I. Instruction 题目连接: http://codeforces.com/gym/100531/attachments Description Ingrid is a he ...

  7. Codeforces Gym 100610 Problem A. Alien Communication Masterclass 构造

    Problem A. Alien Communication Masterclass Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codefo ...

  8. Codeforces Gym 100425H H - Football Bets 构造

    H - Football BetsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  9. Tree Reconstruction Gym - 101911G(构造)

    ---恢复内容开始--- Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given ea ...

随机推荐

  1. GPU硬件加速

    现代浏览器大都可以利用GPU来加速页面渲染.每个人都痴迷于60桢每秒的顺滑动画.在GPU的众多特性之中,它可以存储一定数量的纹理(一个矩形的像素点集合)并且高效地操作这些纹理(比如进行特定的移动.缩放 ...

  2. hdu 1081 To The Max(dp+化二维为一维)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1081 To The Max Time Limit: 2000/1000 MS (Java/Others ...

  3. Webmin LFD to LFI

    Webmin < 1.290 / Usermin < 1.220 - Arbitrary File Disclosure (Perl) https://www.exploit-db.com ...

  4. 【EverydaySport】健身笔记——静态牵拉

    静态牵拉一般在运动后进行,可以有效的提高肌肉的柔韧性和关节的灵活性,预防和缓解疼痛. 每个动作达到自己活动范围的最大,有牵拉感即说明有效,静态保持至少30秒,切勿震荡,进行2组. 1 大腿前群牵拉 2 ...

  5. 【uva10779】收集者的难题

    按照题意建模就行了. #include<bits/stdc++.h> #define naive 0 #define inf 1000000007 using namespace std; ...

  6. Vim配置Node.js开发工具

    ubuntu安装vim编辑器.默认情况下,vim在运行的时候会加载-/.vimrc文件里的配置文件,如果在-目录下不存在这个配置文件可以手动创建. 在-/.vim目录下是vim的插件加载的位置,可以在 ...

  7. 数字签名(以ActiveXDemo为例)

    1.创建Install.inf文件和run.bat Install.inf: [version] signature="$CHICAGO$" AdvancedINF=2.0 [Se ...

  8. linux命令(6):tar命令

    压缩方法:tar zcvf test.tar.gz test [表示把文件夹目录压缩成test.tar.gz文件保存] 解压方法:tar zxvf test.tar.gz –C /home [表示解压 ...

  9. vue 数组和对象不能直接赋值情况和解决方法

    Vue 不能检测以下变动的数组: 当你利用索引直接设置一个项时,例如:vm.items[indexOfItem] = newValue 当你修改数组的长度时,例如:vm.items.length = ...

  10. Two Sum ——经典的哈希表的题

    Given an array of integers, return indices of the two numbers such that they add up to a specific ta ...