[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 ...
随机推荐
- 【DP水题】投票问题(二)
投票问题(一) [试题描述] 欧阳文和欧阳武竞选学联主席,汪梁森负责唱票,共有m+n张,结果欧阳文获胜,已知欧阳文和欧阳武分别获得 m 张票和 n 张票(m>n).现在请你计算在唱票过程中欧阳文 ...
- IT书籍的选择与阅读
拍摄是一件艰苦而有趣的事情. 它需要眼睛和心灵完全融合投入, 需要耐心等待排除干扰, 需要敏捷捕捉稍纵即逝的瞬间. 但是, 非艰苦不成乐趣. 人生也应该选择一件有难度的事情来做. 做不成, 可以收获过 ...
- scala的apply方法
package com.test.scala.test /** * apply 方法 */ object ApplyTest { def main(args: Array[String]): Unit ...
- mac下多个php版本快速切换的方法是怎么样
一.使用brew安装php多版本方法# brew install php56# brew install php70二.安装切换工具# brew install php-version# source ...
- 记录整合sprinmvc+log4j的的过程
简介 由于进一步的学习以及便于自己更好的调试程序中遇到的错误,开始了将log4j整合到web项目中,项目是基于springmvc的,所以就做了一个springmvc和web项目的整合demo,本篇博客 ...
- 浏览器的不兼容,归纳几点html编码要素
1.文字本身的大小不兼容.同样是font-size:14px的宋体文字,在不同浏览器下占的空间是不一样的,ie下实际占高16px,下留白3px,ff下实际占高17px,上留白1px,下留白3px,op ...
- yii2 批量插入or更新
$sql1 = 'insert into business_ip (gid, name, area, belongName, belongArea, destIPv4, created, update ...
- ACM题目————The partial sum problem
描述 One day,Tom’s girlfriend give him an array A which contains N integers and asked him:Can you choo ...
- Android开发:ScrollView嵌套GridView的解决办法
Android开发:ScrollView嵌套GridView的解决办法 前些日子在开发中用到了需要ScrollView嵌套GridView的情况,由于这两款控件都自带滚动条,当他们碰到一起的时候便 ...
- Poj(2784),二进制枚举最小生成树
题目链接:http://poj.org/problem?id=2784 Buy or Build Time Limit: 2000MS Memory Limit: 65536K Total Sub ...