D1.Remove the Substring (easy version) time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output The only difference between easy and hard versions is the length of the string. You are given a string…
D1. RGB Substring (easy version) time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output The only difference between easy and hard versions is the size of the input. You are given a string s consistin…
题意:给你一个模式串\(t\),现在要在主串\(s\)中删除多个子串,使得得到的\(s\)的子序列依然包含\(t\),问能删除的最长子串长度. 题解:首先,我们不难想到,我们可以选择\(s\)头部到最右边的子序列的头部和最左边的子序列的尾部到\(s\)的尾部这两个子串,除去这两个子串,我们要找的最大子串一定在子序列的头部到尾部中,即子序列中两个相邻字符位置的间隔,那么很显然,我们想让相邻的字符之间相隔最大,所以问题也就转化成了:求模式串的相邻字符在主串中的最大间隔长度,最优的情况一定是最左的子序…
任意门:http://codeforces.com/contest/1118/problem/D1 D1. Coffee and Coursework (Easy version) time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The only difference between easy and hard versions…
D2. Remove the Substring (hard version) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The only difference between easy and hard versions is the length of the string. You are given a stri…
D2. Remove the Substring (hard version) 给字符串s,t,保证t为s的子序列,求s删掉最长多长的子串,满足t仍为s的子序列 记录t中每个字母在s中出现的最右的位置, 然后从s开头开始跑 遇到和当前t[j]相同的s[i],j++ 即使得t中相邻两个字符距离最大化 注意j跑完t了,最后一位应该为s的长度 #include<bits/stdc++.h> using namespace std; ]; ]; ]; int main() { scanf("…
题目链接:https://codeforces.com/contest/1203/problem/D2 题意: 给你S串.T串,问你最长删除多长的子串使得S串里仍然有T的子序列. 思路: 想了好久,先正着跑一下S串,记录T串每一个字符最左边在哪里,再倒着跑一下,记录T串的每一个字符最右边在哪里. 最后跑一下答案: 1. 开头和结尾特判一下,但不是max( L[1]-1 , l1-R[l2] ) , 而是对两个max( L[1]-1 , l1-L[l2]-1 ).max( R[1]-1 , l1-…
E.Boxers time limit per test2 seconds memory limit per test256 megabytes inputstdin outputstdout There are…
C.Common Divisors time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given an array…
B.Equal Rectangles time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given 4…