【构造】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 ...
随机推荐
- android 内核调试
这篇文档给出使用android emulator 和 arm-linux-androideabi-gdb 调试 android kernel 的方法 1. checkout goldfish 源码: ...
- centos 安装flash
linux系统中安装flash插件 linux中安装flashplayer插件的简单方法: 1.下载其中最新版本的播放器,下载地址: http://get.adobe.com/cn/flashplay ...
- nodejs 使用redis 管理session
一.在开发机安装redis并远程连接 因本人的远程开发机配置原因,使用jumbo安装redis 首先登录开发机,并使用jumbo 安装redis:jumbo install redis 查看redis ...
- golang锁记
golang中有两个锁实现 atomic的CAS实现锁 首先是inter cpu,熟悉汇编的人都知道,inter指令集有个lock,如果某个指令集前面加个lock,那么在多核状态下,某个核执行到这个前 ...
- Html Css 练习
一. 取消a链接的下划线 <!DOCTYPE html> <html lang="en"> <head> <meta charset=& ...
- Codeforces 877C Slava and tanks(思维)
题目链接:http://codeforces.com/problemset 题目大意:有n个格子,某些格子里可能有一个或多个坦克,但不知道具体位置,每个坦克被轰炸一次就会移动到相邻的格子里(第1个格子 ...
- golang fmt格式占位符
golang 的fmt 包实现了格式化I/O函数,类似于C的 printf 和 scanf. # 定义示例类型和变量 type Human struct { Name string } var peo ...
- Restful Framework (二)
目录 一.认证 二.权限 三.限制访问频率 四.总结 一.认证(补充的一个点) 回到顶部 认证请求头 #!/usr/bin/env python # -*- coding:utf-8 -*- from ...
- Zookeeper之Curator(1)客户端对节点的一些监控事件的api使用
<一>节点改变事件的监听 public class CauratorClientTest { //链接地址 private static String zkhost="172.1 ...
- 620. Not Boring Movies
X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a ...