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> ...
随机推荐
- centos使用--软件启动关闭等操作的命令
关于centos服务的命令经常会遇到这几种 service systemctl /etc/init.d/ 1 service和/etc/init.d/ service是一个脚本命令,分析service ...
- Visual Studio使用技巧笔记(引用程序集自动复制dll到引用项目目录)
copy /y $(TargetPath) $(SolutionDir)\[您项目引用dll文件的目录]\$(TargetFileName) 例如:copy /y $(TargetPath) $(So ...
- Oracle 遇到的问题:IMP-00041: 警告: 创建的对象带有编译警告解决办法
出现IMP-00041: 警告: 创建的对象带有编译警告:以后再做数据迁移的时候需要额外注意,尤其用户中有视图或者触发器对象的时候.用户的环境是这样的,在库里有三个oracle的用户,其中一个用户中有 ...
- css:hover状态改变另一个元素样式的使用
效果演示 css:hover状态改变另一个元素样式的使用 .box { width: 150px; height: 150px; background-color: #069; line-height ...
- [转]LVS+Keepalived负载均衡配置
简介 来源:https://www.cnblogs.com/MacoLee/p/5858995.html lvs一般是和keepalived一起组合使用的,虽然也可以单独使用lvs,但配置比较繁琐,且 ...
- 团队项目-第二次Scrum 会议
时间:10.24 时长:30分钟 地点:线上 工作情况 团队成员 已完成任务 待完成任务 解小锐 学习官方样例 根据初步讨论结果编写初步的api文档 陈鑫 学习cocos creator基本使用 采用 ...
- android 使用LruCache缓存网络图片
加载图片,图片如果达到一定的上限,如果没有一种合理的机制对图片进行释放必然会引起程序的崩溃. 为了避免这种情况,我们可以使用Android中LruCache来缓存下载的图片,防止程序出现OOM. ...
- kvm竟然抓不到kvm的tracepoint
今天终于把kvm给搭起来了,打开了host机的tracepoint竟然一个都没有抓到,这是咋回事? 难道kvm的东西只有在启动的时候才会被抓到? 虚拟出来一块内存一块CPU,虚拟出来一个内存.感觉都好 ...
- ZOJ 1081 Points Within | 判断点在多边形内
题目: 给个n个点的多边形,n个点按顺序给出,给个点m,判断m在不在多边形内部 题解: 网上有两种方法,这里写一种:射线法 大体的思想是:以这个点为端点,做一条平行与x轴的射线(代码中射线指向x轴正方 ...
- js中哪些语句在if语句中默认为真
结论:js中有一个函数是:Boolean(value)这个函数把一个value值转换成相应的boolean值. 当value为以下值是为true:1.任意的非空字符串 .2.任意的非0数字 而当val ...