codeforces 738】的更多相关文章

D: 题意:一行1*n的格子放船只,船数为a,船的长度为b,每格为0或1,1表示该格并不是船只的一部分,找出最少的格子数使得射击这些格子至少能打中一艘船. 思路:船的长度为b,即每段连续的长度为b的0的串都可以放下一只船,射击点为最后一个格子时最优,找出所有的可以放船的位置res个,选择其中的res-a+1个位置. #include<bits/stdc++.h> using namespace std; ]; ]={}; int main() { ,tmp,l,t=; scanf(;i<…
Codeforces Round #738 (Div. 2) 跳转链接 A. Mocha and Math 题目大意 有一个长度为\(n\)的数组 可以进行无数次下面的操作,问操作后数组中的最大值的最小值是多少 - 操作为:选两个位置\([l,r]\) 如果数组中从\(l\)到\(r\)中每个元素\(a_{l+i}\)变为 \(a_{l+i}\)&\(a_{r-i}\) 思路 &操作是对于每一位上的数字,如果有一个\(0\)则当前位置上就为\(0\) 因此我们可以知道 当某个数字某位变成\…
D2. Mocha and Diana (Hard Version) 至于D1,由于范围是1000,我们直接枚举所有的边,看看能不能加上去就行,复杂度是\(O(n^2logn)\).至于\(n\)到了\(1e5\),就要重新考虑解法. 考虑到树的边数是\(n-1\).也就是说我们枚举的大多数边都是无效的,这个时候就要考虑我们能不能只连有效的边,对于两个连通块而言,显然在这两个连通块之间我们只需要连一条边就可以了.还有一般这种两个图的题,一般都是在一个图中操作,在另一个图中进行合不合法的判定.这里…
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…
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's…
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is…
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…
[题目链接]:http://codeforces.com/problemset/problem/738/E [题意] 给你一个类似树形的关系; 然后告诉你某个人头顶上有多少个上司numi; 只有father的father才算是它的上司,father的兄弟不算; 然后告诉你所有的人里面最大boss的标号; 问你最少有多少个numi是错误的; [题解] 会发现; 这里的numi实际上和这个人在树中的深度对应; 则我们把最后的numi数组升序排一下; 如果相邻两个数字它们的差的绝对值不超过1; 且第一…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a…
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…