题目链接:900 E. Maximum Questions 题意: 给出一个长度为n只含有a和b还有'?'的串s,且'?'可以被任意替换为a或b.再给出一个字符串t (奇数位上为a,偶数位上为b,所以在题目中只给出了t的长度m),现在要求保证t在s中出现的次数最多的情况下面,使用'?'最小的情况使用了几个问号. 题解: 拿到这个题目可以看出是DP,但是比较难以解决的就是如何确定在第i个位置时前面m个字符能够满足t,这里我看了别人的题解 -.-哇,震惊!首先的话先对'?'做前缀和,然后设置两个数组…
题目链接: 题目 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…
C. Dreamoon and Strings time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Dreamoon has a string s and a pattern string p. He first removes exactly x characters from s obtaining string s' as a…
D. Dreamoon and Binary time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Dreamoon saw a large integer x written on the ground and wants to print its binary form out. Dreamoon has accomplishe…
传送门 sbsbsb树形dpdpdp题. 题意简述:给出一棵边权为1的树,允许选任意一个点vvv为根,求∑i=1ndist(i,v)∗ai\sum_{i=1}^ndist(i,v)*a_i∑i=1ndist(i,v)∗ai的最大值. 直接统计出子树的权值和转移就行了. 代码: #include<bits/stdc++.h> #define ri register int using namespace std; inline int read(){ int ans=0; char ch=g…
题面 传送门:http://codeforces.com/problemset/problem/833/B B. The Bakery time limit per test2.5 seconds memory limit per test256 megabytes inputstandard input outputstandard output Some time ago Slastyona the Sweetmaid decided to open her own bakery! She…
D - Fox And Jumping Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 512B Description Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integer…