[CF738D]Sea Battle(贪心)
题目链接: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(贪心)的更多相关文章
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- Sea Battle
Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- 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 ...
- Codeforces 738D. Sea Battle 模拟
D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard inp ...
- 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 ...
- 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 ...
- Sea Battle<海战>(思路题)
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 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 ...
- 【42.86%】【Codeforces Round #380D】Sea Battle
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
随机推荐
- memcached +php环境配置和分析
一.memcached 简介 在很多场合,我们都会听到 memcached 这个名字,但很多同学只是听过,并没有用过或实际了解过,只知道它是一个很不错的东东.这里简单介绍一下,memcached 是高 ...
- 全半角空格导致的Sql Server Analysis Services处理错误(转载)
问题描述 某维度表的字符串列同时出现两条记录,A记录以半角空格(英文空格)结束,B记录以全角空格(中文空格)结束,除此之外其他部分均相同.Analysis Service处理的时候抛出“Key not ...
- 5 Best Automation Tools for Testing Android Applications
Posted In | Automation Testing, Mobile Testing, Software Testing Tools Nowadays automated tests ar ...
- android小功能:checkbox使用自己的背景点击切换背景
xiazai_checkbox.xml <?xml version="1.0" encoding="utf-8"?> <selector xm ...
- c++实现mlp神经网络
之前一直用theano训练样本,最近需要转成c或c++实现.在网上参考了一下其它代码,还是喜欢c++.但是看了几份cpp代码之后,发现都多少有些bug,很不爽.由于本人编码能力较弱,还花了不少时间改正 ...
- android 学习随笔十九(对话框、样式、主题、国际化 )
1.对话框 package com.itheima.dialog; import android.os.Bundle; import android.app.Activity; import andr ...
- word2007里插入分节符
1.打开Word文档,将鼠标定位到需要插入分页符的位置(比如第2页的末尾处),切换到"页面布局"功能区. 2.在"页面设置"分组中单击"分隔符&quo ...
- HDU 1890:Robotic Sort(Splay)
http://acm.hdu.edu.cn/showproblem.php?pid=1890 题意:有一个无序序列,经过不断地翻转,使得最后的序列是一个升序的序列,而且如果相同数字要使在原本序列靠前的 ...
- sharepoint 开发
1. 客户端界面搜索 <div> 业务员:<).match(reg); ]);return null; } function search() { var k=document.ge ...
- fastjson和json-lib的区别
上次把原生json替换成了fastjson,发生很多地方不兼容,对这个也做了一些总结: 1.对于没有赋值的变量处理,json-lib会根据类型给出相应初始值,而fastjson直接忽略这个字段. 解决 ...