D. String Game time limit per test:2 seconds memory limit per test:512 megabytes input:standard input output:standard output Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty…
http://codeforces.com/problemset/problem/778/A 题意:给出字符串s和字符串p,还有n个位置,每一个位置代表删除s串中的第i个字符,问最多可以删除多少个字符使得s串依旧包含p串. 思路:想到二分,以为二分做法依旧很暴力.但是别人的做法确实就是二分暴力搞啊. 枚举删除字符数,然后判断的时候如果s串包含p串,那么可以往右区间找,否则左区间找. #include <bits/stdc++.h> using namespace std; #define N…
题目描述 给你一个n×m的矩形,要你找一个子矩形,价值为左上角左下角右上角右下角这四个数的最小值,要你最大化矩形的价值. 输入 第一行两个数n,m,接下来n行每行m个数,用来描述矩形 n, m ≤ 1000 输出 输出一个数表示答案 样例输入 2 2 1 2 3 4 样例输出 1 题解 二分+暴力 首先题目问的是最小值最大,显然二分答案,问题转化为判断是否存在一个子矩形,满足四个角的权值大于等于mid. 考虑暴力怎么做:枚举所有与x轴平行的线段(即同行的线段),判断是否有两个线段的端点横坐标相同…
[BZOJ4716]假摔 Description [题目背景] 小Q最近喜欢上了一款游戏,名为<舰队connection>,在游戏中,小Q指挥强大的舰队南征北战,从而成为了一名dalao.在游戏关卡的攻略中,可能由于作战过程中某艘船受到严重损伤,为避免沉没而被迫进行返航,这种情况大家称为这艘船“假摔”.小Q最喜欢使用的一艘战舰代号为P01,但是最近这艘船总是用各种不同的姿势假摔,于是小Q打算研究一下原因. [题意描述] P01的装甲可以近似看作一个n*m的矩阵,每个位置上的数字代表这个位置装甲…
[Codeforces 1199C]MP3(离散化+二分答案) 题面 给出一个长度为n的序列\(a_i\)和常数I,定义一次操作[l,r]可以把序列中<l的数全部变成l,>r的数全部变成r.每次操作的代价为改变数的个数.问:要让操作后序列里不同数的个数\(k\)满足$n \lceil \log _2 k\rceil \leq 8I $,操作的最小代价 分析 首先把a离散化,这样[l,r]都在\(10^5\)的级别.枚举l,发现r显然有单调性.操作后不同数的个数随r的增大而减小(考虑极端情况l=…
题目链接: http://codeforces.com/contest/651/problem/D D. Image Preview time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya's telephone contains n photos. Photo number 1 is currently opened on…
Grigory loves strings. Recently he found a metal strip on a loft. The strip had length n and consisted of letters "V" and "K". Unfortunately, rust has eaten some of the letters so that it's now impossible to understand which letter was…
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wa…
题目链接:http://codeforces.com/contest/862/submission/30696399 题解:这题一看操作数就知道是二分答案了.然后就是怎么个二分法,有两种思路第一种是找两遍第一遍找1第二遍找0但是这样肯定超时所以还不如直接找相邻的01串或者10串具体查找方法是先将所有串赋值为0这样就能得到1的总个数,然后将所要求的区间全赋值为1其他赋值为0.设num1为总的1的个数反馈的值其实就是表示L-R之间0的个数,然后只要满足(设返回的数为now)只要满足num1-now<…
题目链接:http://codeforces.com/problemset/problem/779/D 题意:有两个字符串一个初始串一个目标串,有t次机会删除初始串的字符问最多操作几次后刚好凑不成目标串 所得结果减1 其实简单匹配只需要n只要二分查找一下答案那么结果就是n*logn #include <iostream> #include <cstring> #include <string> using namespace std; const int M = 2e5…