题目大概说给两个字符串s和t,然后要求一个包含k个字符串的序列,而这个序列是两个字符串的公共子序列,问这个序列包含的字符串的总长最多是多少. 如果用DP解,考虑到问题的规模,自然这么表示状态: dp[i][j][k]表示s[0...i]与t[0...j]包含k个字符串的公共子序列的最大总长 想怎么转移时,我发现这样表示状态不好转移,还得加一维: dp[i][j][k][0]表示s[0...i]与t[0...j]包含k个字符串的公共子序列的最大总长,且s[i]和t[j]不属于序列第k个字符串 dp…
Alyona and Strings 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/D Description After returned from forest, Alyona started reading a book. She noticed strings s and t, lengths of which are n and m respectively. As usual, reading bored Aly…
#include <cstdio> #include <iostream> #include <ctime> #include <vector> #include <cmath> #include <map> #include <stack> #include <queue> #include <algorithm> #include <cstring> using namespace…
题目链接: 题目 D. Alyona and Strings time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output 问题描述 After returned from forest, Alyona started reading a book. She noticed strings s and t, lengths of which are…
题目链接: D. Alyona and Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output After returned from forest, Alyona started reading a book. She noticed strings s and t, lengths of which are n a…
D. Alyona and Strings 题目连接: http://www.codeforces.com/contest/682/problem/D Description After returned from forest, Alyona started reading a book. She noticed strings s and t, lengths of which are n and m respectively. As usual, reading bored Alyona…
题目链接:Codeforces 482C Game with Strings 题目大意:给定N个字符串,如今从中选定一个字符串为答案串,你不知道答案串是哪个.可是能够通过询问来确定, 每次询问一个位置上字符为多少. 如今你询问的每一个位置的概率是同样的,(问过的位置不会再问).求询问次数的期 望. 解题思路:由于字符串长度不会大于20.所以用二进制表示询问了哪些位置.C[s]即为询问s的位置能够确定多少个字 符串. 这步不能通过枚举s,然后推断处理,复杂度为o(2^20 * 20 * 50),太…
D. Alyona and Strings 题意 给出两个字符串s,t,让找出最长的k个在s,t不相交的公共子串. 思路 看了好几个题解才搞懂. 代码中有注释 代码 #include<bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; const int N=1e5+10; const int mod=1e9+7; const int inf=0x3f3f3f3f; char s[N],t…
Codeforce 682 D. Alyona and Strings 解析(思維.DP) 今天我們來看看CF682D 題目連結 題目 略,請直接看原題. 前言 a @copyright petjelinux 版權所有 觀看更多正版原始文章請至petjelinux的blog 想法 首先會感覺應該是類似\(LCS\)的問題,但是有一點變形.因此我們會先想到應該是\(DP\),而可能會想到另外兩個狀態是: 共同部分是不是目前兩個字串前綴的結尾 最小的分段是幾段 也就是\(:dp[i][j][end]…
题目链接:Codeforces 385B Bear and Strings 记录下每一个bear的起始位置和终止位置,然后扫一遍记录下来的结构体数组,过程中用一个变量记录上一个扫过的位置,用来去重. #include <iostream> #include <cstdio> #include <cstring> using namespace std; const int MAX_N = 5000 + 100; char str[MAX_N]; struct Node…