Codeforces Technocup 2017 - Elimination Round 2 D. Sea Battle(贪心)
题目链接 http://codeforces.com/contest/729/problem/D
题意:给你一个1*n的区域有a艘船,每艘船宽b,已经开了k枪都没打到,问你最少再开几枪至少能打到一艘船。
想清楚了挺简单的,只要找到所有船可能放的地方然后存下再找任意sum-a+1个位置即可。
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int M = 2e5 + 10;
char s[M];
int main()
{
int n , a , b , k;
cin >> n >> a >> b >> k;
cin >> s;
vector<int>q;
int len = strlen(s);
for(int i = 0 ; i + b - 1 < n ; ++i) {
int flag = 0;
for(int j = 0 ; j < b && i < n ; ++j , ++i) {
if(s[i] == '1') {
flag = 1;
break;
}
}
if(!flag) {
q.push_back(i - 1);
i--;
}
}
int gg = q.size() - a + 1;
cout << gg << endl;
for(int i = 0 ; i < gg ; i++) {
cout << q[i] + 1 << ' ';
}
return 0;
}
Codeforces Technocup 2017 - Elimination Round 2 D. Sea Battle(贪心)的更多相关文章
- Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 2) D. Sea Battle 模拟
D. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Technocup 2017 - Elimination Round 2 E Subordinates(贪心)
题目链接 http://codeforces.com/contest/729/problem/E 题意:给你n个人,主管id为s,然后给你n个id,每个id上对应一个数字表示比这个人大的有几个. 最后 ...
- Codeforces Round #380 (Div. 1, Rated, Based on Technocup 2017 - Elimination Round 2)
http://codeforces.com/contest/737 A: 题目大意: 有n辆车,每辆车有一个价钱ci和油箱容量vi.在x轴上,起点为0,终点为s,中途有k个加油站,坐标分别是pi,到每 ...
- Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) C
Description Santa Claus has Robot which lives on the infinite grid and can move along its lines. He ...
- Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) B
Description Santa Claus decided to disassemble his keyboard to clean it. After he returned all the k ...
- Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) A
Description Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the f ...
- Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) D. Santa Claus and a Palindrome STL
D. Santa Claus and a Palindrome time limit per test 2 seconds memory limit per test 256 megabytes in ...
- Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) E. Santa Claus and Tangerines
E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- codeforces Codeforces Round #380 (Div. 1, Rated, Based on Technocup 2017 - Elimination Round 2)// 二分的题目硬生生想出来ON的算法
A. Road to Cinema 很明显满足二分性质的题目. 题意:某人在起点处,到终点的距离为s. 汽车租赁公司提供n中车型,每种车型有属性ci(租车费用),vi(油箱容量). 车子有两种前进方式 ...
随机推荐
- tensorflow学习笔记——常见概念的整理
TensorFlow的名字中已经说明了它最重要的两个概念——Tensor和Flow.Tensor就是张量,张量这个概念在数学或者物理学中可以有不同的解释,但是这里我们不强调它本身的含义.在Tensor ...
- 免安装版tomcat安装成服务
安装方式(前提已经安装好了jdk,并配置了环境量): (1) 下载非exe的tomcat zip包: (2) 解压缩,如:D:\tomcat: (3) 进入D:\tomcat\bin,修改servic ...
- x32下PsSetLoadImageNotifyRoutine的逆向
一丶简介 纯属兴趣爱好.特来逆向玩玩. PsSetLoadImageNotifyRoutine 是内核中用来监控模块加载.操作系统给我们提供的回调. 我们只需要填写对应的回调函数原型即可进行加监控. ...
- Zabbix在 windows下监控网卡
1.zabbix自定义监控Windows服务器的原理 Zabbix为Windows服务器的监控提供了PerfCounter(性能计数器)这个功能.Zabbix客户端通过PerfCounter获取Win ...
- solidity智能合约字节数最大值及缩减字节数
智能合约最大字节数 在Solidity中,EIP 170将contract的最大大小限制为24 KB .因此,如果智能合约内容过多,会导致无法进行发布操作. 减少压缩字节数方法 方法及变量命名 在一定 ...
- 10、二维数组的申请(test7.java)
我个人认为,二维数组的构造就是在一位数组中存入一个地址,这个地址指向另一个一位数组,这样通过这种排列组合便构造成了二维数组. 二维数组的形状,有的时候二维数组看起来像是一个矩阵,所以一般情况下如果涉及 ...
- macos Mojave 出现网络出错 Frame Check Sequence: Bad checksum
问题描述:使用软电话外呼的时候出现Request Timeout . 端口监听之后通过 Wireshark发现错误:`Frame Check Sequence: Bad checksum`,查看wir ...
- iView 实现可编辑表格
create at: 2019-02-20 组件 <i-table highlight-row ref="currentRowTable" :columns="co ...
- 调用链系列(1):解读UAVStack中的贪吃蛇
一.背景 对于分布式在线服务,一个请求需要经过多个系统中多个模块,可能多达上百台机器的协作才能完成单次请求.这种场景下单靠人力无法掌握整个请求中各个阶段的性能开销,更无法快速的定位系统中性能瓶颈.当发 ...
- js五子棋游戏代码分享
HTML代码 <canvas id="game"></canvas> CSS代码 * { margin: 0; padding: 0; } #game { ...