$AT2163\ Median\ Pyramid\ Easy$ 构造
正解:构造
解题报告:
考虑如果有两个相邻格子是相同数字那么它们以上这两列就都会是这列数字(显然$QwQ$?
所以考虑只要构造出第$n-1$行的中心和中心右侧($or$左侧一样的$QwQ$都等于$x$,其他格子随便填就成鸭$QwQ$
然后就做完辣?记得分类讨论几个特殊情况嗷$QwQ$
$over$
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define gc getchar()
#define mp make_pair
#define P pair<int,int>
#define ri register int
#define rb register bool
#define rc register char
#define t(i) edge[i].to
#define w(i) edge[i].wei
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)
#define e(i,x) for(ri i=head[x];i;i=edge[i].nxt) const int N=2e5+;
int n,x,a[N],tmp;
bool vis[N]; il int read()
{
rc ch=gc;ri x=;rb y=;
while(ch!='-' && (ch<'' || ch>''))ch=gc;
if(ch=='-')ch=gc,y=;
while(ch>='' && ch<='')x=(x<<)+(x<<)+(ch^''),ch=gc;
return y?x:-x;
} int main()
{
n=read();x=read();if(x== || x==n*-)return printf("No\n"),;printf("Yes\n");
if(x==){a[n]=;a[n+]=;tmp=;n=n*-;rp(i,,n)if(!a[i])a[i]=++tmp;rp(i,,n)printf("%d\n",a[i]);return ;}
a[n]=x;a[n+]=x+;a[n-]=x-;a[n+]=x-;vis[x]=vis[x+]=vis[x-]=vis[x-]=;
tmp=;n=n*-;rp(i,,n)if(!a[i]){while(vis[tmp])++tmp;a[i]=tmp;vis[tmp]=;}rp(i,,n)printf("%d\n",a[i]);
return ;
}
随机推荐
- Hbase架构与实现
- 【[Offer收割]编程练习赛9 B】水陆距离
[题目链接]:http://hihocoder.com/problemset/problem/1478 [题意] [题解] 一开始把所有的水域的位置都加入到队列中去; 然后跑一个bfs. 第一次到达的 ...
- @noi.ac - 506@ 强连通分量
目录 @description@ @solution@ @accepted code@ @details@ @description@ 有一天你学了一个叫能求出有向图中所有的强连通分量的算法,你决定将 ...
- Android 自定义界面的弹出框(可输入数据)
上午写了一篇博文,介绍了如何定义从屏幕底部弹出PopupWindow,写完之后,突然想起之前写过自定义内容显示的弹出框,就随手写了两个实例,分享出来: 第一种实现方式:继承Dialog 1.1 线定义 ...
- linux lvm删除导致无法启动
要想编辑/etc/fstab文件,我们需要在系统中重新挂载根目录,使其具有可读写状态,使用如下命令: mount -o remount,rw / 该条命令的作用是,以可读写的形式重新挂载根分区. 然后 ...
- C#的循环语句(一)
循环:反复执行某段代码. 循环四要素:初始条件,循环条件,循环体,状态改变.for(初始条件;循环条件;状态改变) {循环体} for 格式: for(int i=1/*初始条件*/;0<=10 ...
- HDU 2546 01背包问题
这里5元是个什么意思呢.差不多就是特殊情况了. 就是说最贵的那个东西先不买.并且最后要留下5元去买那个最贵的. 也就是说对现在金钱-5 拿剩下的钱去对减去最贵的商品后的商品dp.看这些剩下的钱能买多少 ...
- Vue 父组件往子组件传递方法
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- SpringBoot+Thyemleaf开发环境正常,打包jar发到服务器就报错Template might not exist or might not be accessible
网上查看了各种解决的思路,总结如下: 1. 在controller层请求处理完了返回时,没有使用@RestController或@ResponseBody而返回了非json格式 这种情况下返回的数据t ...
- H3C RIPv2配置任务