$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 ;
}
随机推荐
- @atcoder - Japanese Student Championship 2019 Qualification - E@ Card Collector
目录 @description@ @solution@ @accepted code@ @details@ @description@ N 个卡片放在 H*W 的方格图上,第 i 张卡片的权值为 Ai ...
- @bzoj - 2388@ 旅行规划
目录 @description@ @solution@ @accepted code@ @details@ @description@ 请你维护一个序列,支持两种操作: (1)某个区间 [x, y] ...
- Pointers and Arrays_4
1.编写程序expr,以计算从命令行输入的逆波兰表达式的值,其中每个运算符或操作数用一个单独的参数表示.例如,命令expr 2 3 4 + * 将计算表达式2×(3+4) 的值. #include & ...
- C++ sort使用两个参数来排序
排序在编程中经常用到,冒泡法排序时间复杂度高,使用C++库函数sort可以快速排序. 1.必须的头文件#include < algorithm>和using namespace std; ...
- px em rem %作为单位使用
博客地址 :https://www.cnblogs.com/sandraryan/ px 我们都很熟悉啦,但是固定大小无法适配各种屏幕. rem是CSS3新增的一个相对单位(root em,根em), ...
- 使用openssl 工具进行双向认证测试
1,双向认证测试(需要根证书,客户证书,服务器证书以及各自的私钥)(验证通信双方的身份) openssl s_server -accept -key certs/server.key -cert ce ...
- hdu 3339 In Action(迪杰斯特拉+01背包)
In Action Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- Vue 动画的钩子函数
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 【React】react项目引入echarts插件 K线图
参考npm文档:https://www.npmjs.com/package/echarts-for-react 由于npm上已经有针对react项目出的echarts插件,所以在这里直接安装 第一步: ...
- 关于移动端弹层下的body滚动
关于移动端弹层下的body滚动 这个问题在移动端挺常见的,网上也有一些解决方法,现在笔者来总结一下:css的解决方案都有兼容问题,js是比较稳定的解决方法(虽然比较麻烦) ps: 本文的例子都是用vu ...