cf B. Dima and Text Messages】的更多相关文章

http://codeforces.com/contest/358/problem/B 先按照题意说的构造一个字符串s,然后与对比的字符串T比较,看看在字符串T中顺序查找有没有字符串S的所有字符,有输出yes,否则输出no. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ],s[]; int n; int main() { while(scanf("…
题目链接:http://codeforces.com/problemset/problem/358/B 题目意思:给出n个单词(假设为word1,word2.word3...wordn)和一句test message,需要判断的是,这个 test message在去除一系列随机插入的英文字符后,是否满足<3word1<3word2<3 ... wordn<3 的结构. 首先要构造出一个参考序列,也就是<3word1<3word2<3 ... wordn<3的…
#include <iostream> #include <algorithm> #include <string> using namespace std; int main(){ int n; cin >> n; string words = "<3",tmp; ; i < n ; ++ i){ cin >> tmp; words +=tmp+"<3"; } string messag…
http://codeforces.com/contest/366/problem/D 遍历下界,然后用二分求上界,然后用dfs去判断是否可以. #include <cstdio> #include <cstring> #include <algorithm> #define maxn 10000 using namespace std; int n,m; int head[maxn]; bool vis[maxn]; int e; int pl[maxn],pr[ma…
题目链接:http://codeforces.com/problemset/problem/366/E 题意:给出一个n*m的数字矩阵A,每个矩阵元素的范围[1,K].给出一个长度为s的数字串B,B的每个元素的范围[1,K].将B中的每个元素t用A中的一个位置(i,j)代替,满足A[i][j]=B[t].这样就得到一个长度为s的位置序列.定义相邻两个位置的距离为曼哈顿距离,定义序列的最大距离为每两个相邻元素距离最大值.求一种替换方案使得序列的最大距离最大. 思路:最后转化成两个位置集合S1,S2…
http://codeforces.com/contest/366/problem/E |x1-x2|+|y1-y2|有四种情况 1.-(x1-x2)+(y1-y2); 2.(x1-x2)-(y1-y2); 3.-(x1-x2)-(y1-y2); 4.(x1-x2)+(y1-y2); 可以先把没一个数的坐标分为上面的四种情况存起来,然后在S序列相邻的两个数的曼哈顿距离最大就是两个数中的一个数的四种情况最大值减去另一个数的最小值. #include <cstdio> #include <c…
http://codeforces.com/contest/366/problem/C 转化为背包问题,可以将a[i]-b[i]*k看成重量,a[i]为价值: 因为a[i]-b[i]*k可以为负数,所以应该分开讨论.结果就是dp[10000],如果等于0则输出-1,否则输出dp[10000]; #include <cstdio> #include <cstring> #include <algorithm> #define maxn 500005 using names…
http://codeforces.com/contest/366/problem/B 从0到k枚举起点,然后i+k判断是不是i+k>=n如果是i=(i+k)%n;否则i=i+k; #include <cstdio> #include <cstring> #include <algorithm> #define maxn 200010 using namespace std; <<; int n,k; int a[maxn]; bool vis[max…
http://codeforces.com/contest/358/problem/D 题意:ai代表相邻的两个野兔都没有吃食物情况下的快乐系数,bi代表的是在相邻的两个野兔中有一个吃到食物的快乐系数,ci代表的是相邻的两个野兔都迟到事物的快乐系数,给你n个野兔的快乐系数,求最大快乐系数. dp[i][0]表示先于i+1个吃到食物的最大快乐系数,dp[i][1]表示后于i+1个吃到食物的最大快乐系数. #include <cstdio> #include <cstring> #in…
http://codeforces.com/contest/358/problem/C 将最大的放在stack里面,第二大的放在queue中,第三大的放在deck里面.然后模拟就可以了. #include <cstdio> #include <cstring> #include <queue> #include <algorithm> using namespace std; ]; priority_queue<int ,vector<int&g…