Ac日记——Distances to Zero codeforces 803b
思路:
水题;
代码:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; #define maxn 200005 int ai[maxn],bi[maxn],ci[maxn],n; inline void in(int &now)
{
char Cget=getchar();now=;
while(Cget>''||Cget<'') Cget=getchar();
while(Cget>=''&&Cget<='')
{
now=now*+Cget-'';
Cget=getchar();
}
} int main()
{
in(n);int cnt=maxn+,pos=maxn+;
for(int i=;i<=n;i++) in(ai[i]);
for(int i=;i<=n;i++) bi[i]=ai[i]?++cnt:cnt=;
for(int i=n;i>=;i--) ci[i]=ai[i]?++pos:pos=;
for(int i=;i<=n;i++) printf("%d ",min(bi[i],ci[i]));
return ;
}
Ac日记——Distances to Zero codeforces 803b的更多相关文章
- Distances to Zero CodeForces - 803B (二分)
题目链接:https://vjudge.net/problem/CodeForces-803B#author=0 题意: 给你一个数组,其中至少包括一个0,求每一个元素距离最近一个0的距离是多少. 样 ...
- AC日记——Dynamic Problem Scoring codeforces 807d
Dynamic Problem Scoring 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <io ...
- AC日记——Sign on Fence Codeforces 484e
E. Sign on Fence time limit per test 4 seconds memory limit per test 256 megabytes input standard in ...
- AC日记——Sagheer, the Hausmeister codeforces 812b
812B - Sagheer, the Hausmeister 思路: 搜索: 代码: #include <cstdio> #include <cstring> #includ ...
- AC日记——Sagheer and Crossroads codeforces 812a
812A - Sagheer and Crossroads 思路: 模拟: 代码: #include <cstdio> #include <cstring> #include ...
- AC日记——Is it rated? codeforces 807a
Is it rated? 思路: 水题: 代码: #include <cstdio> #include <cstring> using namespace std; ],b[] ...
- AC日记——Mice and Holes codeforces 797f
797F - Mice and Holes 思路: XXYXX: 代码: #include <cmath> #include <cstdio> #include <cst ...
- AC日记——Roma and Poker codeforces 803e
803E - Roma and Poker 思路: 赢或输或者平的序列: 赢和平的差的绝对值不得超过k: 结束时差的绝对值必须为k: 当“?”时可以自己决定为什么状态: 输出最终序列或者NO: dp( ...
- AC日记——Periodic RMQ Problem codeforces 803G
G - Periodic RMQ Problem 思路: 题目给一段序列,然后序列复制很多次: 维护序列很多次后的性质: 线段树动态开点: 来,上代码: #include <cstdio> ...
随机推荐
- JAVA中使用AES加密解密
技术交流群: 233513714 /** * AES加密测试 * * @param str 加密参数 */ public void aesTest(String str) { log.info(&qu ...
- laravel5.5配置信息
目录 1 环境配置 1.1 检索环境配置 1.2 确定当前环境 2 访问配置值 3 配置缓存 4 维护模式 配置文件在config目录下,为了便于不同人员的开发,我们可以使用不同的.env文件来配置各 ...
- C#方法参数
使用静态字段来模拟全局变量. 如果调用者想要得到被调用者的值: 1.返回值 2.不管是实参还是形参,都是在内存中开辟了空间的. 3.方法的功能一定要单一. GetMax(int n1,int n2) ...
- 关于safaire下hash前面需要加/(正斜杠)
就是我们1.1框架是根据hash跳转的,今天我2.0跳转到1.1,pc一直测下来都是好的, 然后发现手机上一直跳转有问题,然后排查了半小时左右才发现 hash前面需要加/ 分割. 例如:http:/ ...
- Git上手:Git扫盲区
Git 自述Git 是由伟大的电脑程序员Linus Torvalds编写的一个开源的,分布式的版本控制系统软件. Git 核心原理Git 利用底层数据结构,通过指向索引对象的可变指针,保存文件快照. ...
- 珍藏版 Python 开发工程师面试试题
珍藏版 Python 开发工程师面试试题 说明:不拿到几家公司的offer,那就是卑鄙的浪费 一.Python_基础语法 1.可变与不可变类型: 2.浅拷贝与深拷贝的实现方式.区别:deepcopy如 ...
- 添加selenium对应的jar包至pom.xml
1.进入https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java,点开相应的版本 2.复制图中选中的代码,粘贴至 ...
- Windows7中如何让python2和python3共存并使用pip
1.下载安装python2和python3 分别下载python2.7.exe.python3.6.exe并安装到C盘.E盘(如图) 2.配置环境变量 打开“系统变量”中的path文本框(如图 ...
- Jmeter获取Cookie并传递到下一个线程---跨线程后cookie找不到了
网上找了一堆文章没有一个是实际操作的,自己边试边查边摸索终于找到了一个全套的办法. 原创文章,转载请说明出处. 1.取得cookie 直接这样写就可以了${COOKIE_JSESSIONID},当然具 ...
- 网络--OSI七层模型详解
OSI 七层模型通过七个层次化的结构模型使不同的系统不同的网络之间实现可靠的通讯,因此其最主要的功能就是帮助不同类型的主机实现数据传输 . 完成中继功能的节点通常称为中继系统.在OSI七层模型中,处于 ...