Problem  Codeforces Round #556 (Div. 2) - D. Three Religions Time Limit: 3000 mSec Problem Description Input Output Sample Input 6 8abdabc+ 1 a+ 1 d+ 2 b+ 2 c+ 3 a+ 3 b+ 1 c- 2 Sample Output YESYESYESYESYESYESNOYES 题解:动态规划,意识到这个题是动态规划之后难点在于要优化什么东西,本题…
题目链接:http://codeforces.com/contest/1150/problem/D 题目大意: 你有一个参考串 s 和三个装载字符串的容器 vec[0..2] ,然后还有 q 次操作,每次操作你可以选择3个容器中的任意一个容器,往这个容器的末尾添加一个字符,或者从这个容器的末尾取出一个字符. 每一次操作之后,你都需要判断:三个容器的字符串能够表示成 s 的三个不重叠的子序列. 比如,如果你的参考串 s 是: abdabc 而三个容器对应的字符串是: vec[0]:ad vec[1…
Problem  Codeforces Round #556 (Div. 2) - D. Three Religions Time Limit: 1000 mSec Problem Description Input Output Sample Input 51 2 1 2 1 Sample Output 1 1 1 2 2 题解:这个题有做慢了,这种题做慢了和没做出来区别不大... 读题的时候脑子里还意识到素数除了2都是奇数,读完之后就脑子里就只剩欧拉筛了,贪心地构造使得前缀和是连续的素数,那…
Codeforces Round #556 (Div. 1) A. Prefix Sum Primes 给你一堆1,2,你可以任意排序,要求你输出的数列的前缀和中质数个数最大. 发现只有\(2\)是偶质数,那么我们先放一个\(2\),再放一个\(1\),接下来把\(2\)全部放掉再把\(1\)全部放掉就行了. #include<iostream> #include<cstdio> using namespace std; inline int read() { int x=0;bo…
比赛链接 A 贪心 #include <cstdlib> #include <cstdio> #include <algorithm> #include <cmath> #include <cstring> #include <queue> #include <vector> #include <set> using namespace std; const int N = 1005; int a[N], b[…
A. Stock Arbitraging 直接上代码: #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<queue> #include<stack> #include<set> #include<map> #include<vector> #include<cmath>…
C. Tennis Championship 题目链接 http://codeforces.com/contest/735/problem/C 题面 Famous Brazil city Rio de Janeiro holds a tennis tournament and Ostap Bender doesn't want to miss this event. There will be n players participating, and the tournament will fo…
C. Coloring Trees 题目连接: http://www.codeforces.com/contest/711/problem/C Description ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The…
A. Reberland Linguistics 题目连接: http://www.codeforces.com/contest/666/problem/A Description First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The educati…
Codeforces Round #556 题解 Div.2 A Stock Arbitraging 傻逼题 Div.2 B Tiling Challenge 傻逼题 Div.1 A Prefix Sum Primes 傻逼题,先放2,1然后放完2然后放完1 Div.1 B Three Religions 有三个字符串\(s_1,s_2,s_3\)和一个主串\(s\),每次操作改变一个\(s_i\)(插入或删除字符),每次操作完之后问\(s\)是否可以分成\(3\)个子序列正好是\(s_1,s_…