CodeForces 738D Sea Battle】的更多相关文章

D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard input output: standard output Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships…
抽屉原理. 先统计最多有$sum$个船可以放,假设打了$sum-a$枪都没打中$a$个船中的任意一个,那么再打$1$枪必中. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include…
http://codeforces.com/contest/738/problem/D https://www.cnblogs.com/flipped/p/6086615.html   原 题意:海战棋游戏,长度为n的01串,1代表炸过且没有船的位置,0代表没有炸过的位置.有a个船,长度都是b,求打到一艘船至少还需要多少炸弹,并输出炸的位置. 分析:每连续的b个0就要炸一次,不然不知道有没有是不是刚好一艘船在这b个位置上面.贪心可知炸这b个的最后一个最划算.因为只要炸到一艘即可,所以答案减去a-…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecu…
D. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships con…
D. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships con…
D. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships con…
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other. Galya doesn't know…
Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consis…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecu…
A. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In order to make the "Sea Battle" game more interesting, Boris decided to add a new ship type to it. The ship consists of…
链接:https://codeforces.com/contest/1131/problem/A 题意: 给两个矩形,一个再上一个在下,求两个矩形合并的周围一圈的面积. 思路: 因为存在下面矩形宽度大于上面,所以先求下面矩形周围面积,再求上方矩形最下一行除外的面积. 代码: #include <bits/stdc++.h> using namespace std; typedef long long LL; int main() { int w1, h1, w2, h2; cin >&g…
题目链接 http://codeforces.com/contest/729/problem/D 题意:给你一个1*n的区域有a艘船,每艘船宽b,已经开了k枪都没打到,问你最少再开几枪至少能打到一艘船. 想清楚了挺简单的,只要找到所有船可能放的地方然后存下再找任意sum-a+1个位置即可. #include <iostream> #include <cstring> #include <algorithm> #include <vector> using n…
题意: 有n个格子,a条船,每条船占b个格子.事先已经射击了k个格子,且这k次射击不会射到船上,求再射击几次可以射到某一条船的某一部分 思路: 观察样例可以发现,如果五个0,船的长度是3,那么这五个0中可能有 1 2 3 2 3 4 3 4 5 这三种位置都包含3这个id,所以,我们只需要射击到3这个位置就可以射击到船的某一部分 所以,我们只需要统计有多少个连续的0,就可以得到这连续的0中可能包含的船的条数,进而计算出最少的射击次数,也就是0的个数除以船的长度. 得到了总的设计次数,将其减去船的…
题目链接:http://codeforces.com/problemset/problem/567/D 题目意思:给出 1 * n 的 field,编号从左至右依次为 1,2,...,n.问射 m 枪之后(第 i 次射中编号 xi,则 xi 这一点是不能放置船只的!),能不能将 k 只 1 * a 的小船放到这些没有经过被射中编号的 field 中 .由于Alice 每次 shoot 的时候都会说 miss 的,即没有打中,你需要判断第几次shoot 使得整个field 不能放置 k 只 小船,…
传送门 D. One-Dimensional Battle Ships time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a line con…
题目链接: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; ; int n,…
题目:51nod: 题目Codeforces: 题目注意到两个战舰不能挨在一起就可以了. // 每一段 struct node{ int left; // 段的左端点 int right; // 段的右端点 int length; // 段长度 int ship; // 段最大容纳战舰数 }arr[]; 每一段可容纳战舰数: ship*a + (ship - 1) <= length;   -->   ship = (length+1) / (a+1);(舍去小数部分) 构造出这么一个数据结构…
题目链接:https://codeforces.com/problemset/problem/567/D 题意: 在一个 $1 \times n$ 的网格上,初始摆放着 $k$ 只船,每只船的长度均为 $a$ 个格子,已知所有船之间均不重叠.不触碰. 现在Bob每次询问Alice第 $i$ 个格子上是否存在船,Alice每次都会说不存在,求在第几次询问时,可以确定Alice撒谎了. 题解: 对于某次询问一个位置 $x$ 是否有船,假设其属于某个最小的区间 $(l,r)$,其中 $l,r$ 分别是…
原文链接https://www.cnblogs.com/zhouzhendong/p/CF1045D.html 题目传送门 - CF1045D 题意 给定一棵有 $n$ 个节点的树,第 $i$ 个节点有 $p_i$ 的概率消失.有 $q$ 次操作,每次操作修改一个节点消失的概率,请你在每一次操作之后输出树的期望连通块个数. $n,q\leq 10^5$ 题解 首先我们考虑如何求解不操作的情况. 考虑期望的线性性,我们统计每一个节点对答案的负贡献. 首先,假装每一个节点都是一个连通块. 对于节点…
A. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In order to make the "Sea Battle" game more interesting, Boris decided to add a new ship type to it. The ship consists of…
目录 Codeforces 1131 A.Sea Battle B.Draw! C.Birthday D.Gourmet choice(拓扑排序) E.String Multiplication(思路) F.Asya And Kittens(链表) G.Most Dangerous Shark Codeforces 1131 比赛链接 hack一个暴力失败了两次最后还是没成功身败名裂= = CF跑的也太快了吧... 不过倒也涨了不少. A.Sea Battle //想麻烦了,但是无所谓... #…
链接:http://codeforces.com/contest/1131 A Sea Battle 利用良心出题人给出的图,不难看出答案为\(2*(h1+h2)+2*max(w1,w2)+4\)由于\(w2 \leq w1\),所以答案为\(2*(h1+h2)+2*w1+4\) #include<cstdio> int w1,h1,h2,w2,ans; int main(){ scanf("%d%d%d%d",&w1,&h1,&w2,&h2…
因为这次难得不在十点半(或是更晚),大家都在打,然后我又双叒叕垫底了=.= 自己对时间的分配,做题的方法和心态还是太蒻了,写的时候经常写一半推倒重来.还有也许不是自己写不出来,而是在开始写之前就觉得自己写不出来 多打CF A.Sea Battle 讨论.jpg 也有式子的解法,我没想 B.Draw 讨论失败.jpg (写题顺序:ADFC,没有B) 讨论个**,转化成线段求交,答案就是$\sum max(0,min(x,y)-max(lstx,lsty)+(lstx!=lsty))$,记得加上一开…
A. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In order to make the "Sea Battle" game more interesting, Boris decided to add a new ship type to it. The ship consists of…
https://www.cnblogs.com/31415926535x/p/10427505.html codeforces-1131A~G 这场很多题都很简单,,应该是要能至少做出4道的,,但是我一道wa了懵逼一道不知道如何写代码实现链表,,又是掉分场,,QAQ,,, A. Sea Battle 求两个左对齐的矩形的外围一圈的面积(方格数),,,一开始去想着一层一层的找规律去推公式去了,,,推到一半发现越来越乱,,又想了一会才想起直接分成两个矩形:红色的扩大一圈后的和去掉一层后的蓝色的矩形的…
D. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships con…
D. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships con…
A. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In order to make the "Sea Battle" game more interesting, Boris decided to add a new ship type to it. The ship consists of…