题目链接:http://codeforces.com/contest/738/problem/D

题意:1*n的格子里有a条长为b的船。有一个人射了k发子弹都没打中船,现在问最少再打多少次一定能保证射到一搜。

统计出每一个子块中最多能多少条船,贪心地从左到右排列,记下船尾。假设有m条,那么除了m-a条船,剩下的位置一定能打中一条。就是打m-a+1个地方,随便打m-a+1个船尾就行了。

 #include <bits/stdc++.h>
using namespace std; const int maxn = ;
int n, a, b, k;
char s[maxn];
vector<int> shoot;
vector<int> seg;
vector<int> bg, ed; int main() {
// freopen("in", "r", stdin);
while(~scanf("%d%d%d%d",&n,&a,&b,&k)) {
scanf("%s", s+);
int cnt = ;
seg.clear();
for(int i = ; i <= n; i++) {
if(s[i] == '') {
cnt = ;
}
else if(s[i] == '') {
cnt++;
if(cnt == b) {
seg.push_back(i);
cnt = ;
}
}
}
int sz = seg.size();
printf("%d\n", sz);
sz = sz - a + ;
for(int i = ; i < sz; i++) {
printf("%d%c", seg[i], i == sz - ? '\n' : ' ');
}
}
return ;
}

[CF738D]Sea Battle(贪心)的更多相关文章

  1. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  2. Sea Battle

    Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

  3. Codeforces Round #380 (Div. 2)D. Sea Battle

    D. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  4. Codeforces 738D. Sea Battle 模拟

    D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard inp ...

  5. Codeforces #380 div2 D(729D) Sea Battle

    D. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  6. 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 ...

  7. Sea Battle<海战>(思路题)

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. Codeforces Round #380 (Div. 2)/729D Sea Battle 思维题

    Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the ...

  9. 【42.86%】【Codeforces Round #380D】Sea Battle

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

随机推荐

  1. 锋利的JQuery(五)

    jQuery与Ajax: load: load(url)   $("#resText").load("test.html")  加载所有元素 load(url ...

  2. OpenStack 之vmware机器迁移到openstack集群

    原理 openstack本身是支持使用vmware格式的镜像的,但是是需要我们我们在/etc/nova/nova.conf的配置文件中指定该计算节点使用vmware的驱动 1 2 3 4 5 6 7 ...

  3. Error: 16GU盘变1G,恢复

    最近装win10,chromium os之后,删除U盘中的文件,发现不能删除,脑子一热格式化了,发现16G突然变成了1G,这不是坑爹吗,刚买的新U盘呀.立马百度,发现有说是买的被骗了,有的说使用某个软 ...

  4. Linux内核抢占与中断返回【转】

    转自:http://blog.csdn.net/tommy_wxie/article/details/7425728 版权声明:本文为博主原创文章,未经博主允许不得转载. [html] view pl ...

  5. Rsync原理介绍及配置应用

    1.前言 基于LAN或WAN的网络应用之间进行数据传输或者同步非常普遍,比如远程数据镜像.备份.复制.同步,数据下载.上传.共享等等.对此,最简单.直接的做法是对数据进行完全复制.然而,数据在网络上来 ...

  6. DECODE函数

    DECODE函数相当于一条件语句(IF),它将输入数值与函数中的参数列表相比较,根据输入值返回一个对应值.函数的参数列表是由若干数值及其对应结果值组成的若干序偶形式.当然,如果未能与任何一个实参序偶匹 ...

  7. ECshop中defined('IN_ECS')的实现原理

    在PHP中经常看到如下代码   if (!defined('IN_ECS'))   {       die('Hacking attempt');   }   实现的原因以及原理如下:     ecs ...

  8. ReactDom.render和React.render的区别

    这个是react最新版api,也就是0.14版本做出的改变.主要是为了使React能在更多的不同环境下更快.更容易构建.于是把react分成了react和react-dom两个部分.这样就为web版的 ...

  9. Communication System(dp)

    Communication System Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 25006 Accepted: 8925 ...

  10. 使用C#写windows服务

    首先,创建一个windows服务项目