Codeforces 675B Restoring Painting】的更多相关文章

链接:传送门 题意:给出3 × 3的方块,其中任意2 × 2的方块和左上角2 × 2的和相等,还给出9个格子中的4个--a,b,c,d ,在1~n中选择一些数(可重复)填入剩下5个格子中,问有多少种填法 思路:设5个 ?分别为x1,x2,x3,x4,x5 ,最后合并整理可以求得两个式子: x4 - x2 = a - b + c - d x5 - x1 = a + b - c - d 先遍历x4 然后二分 x2 ,O(2nlog(n))的复杂度,理论上是没问题的 /****************…
题目链接: B. Restoring Painting time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he…
B. Restoring Painting 题目连接: http://www.codeforces.com/contest/675/problem/B Description Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he h…
Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painting. He remembers some facts about it. The painting is a…
Codeforces 1132 C 题意:给一些区间\([l_i,r_i]\),从中删掉两个,求剩下的区间最多能够覆盖的格子数量. 思路:首先枚举第一个删掉的区间,然后我们可以通过差分来求出每个格子被多少个区间覆盖了,随后求出所有格子中被\(1\)个区间覆盖的数量的前缀和,再枚举第二个删掉的区间,找删掉的\(1\)个区间覆盖的最少的即为答案. Codeforces 1132 C 分析 tataky: 首先我们将所有的互不包含的区间们放在\(v\)里,然后看被包含的区间有多少,如果超过2个就直接输…
898F - Restoring the Expression 思路:字符串hash,base是10,事实证明对2e64取模会T(也许ull很费时),对1e9+7取模. 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ull unsigned long long #define mem(a,b) memset(a,b,sizeof(a)) ; ;…
递归.分治. . . C. Painting Fence time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Bizon the Champion isn't just attentive, he also is very hardworking. Bizon the Champion decided to paint his ol…
[题目链接]:http://codeforces.com/contest/509/problem/B [题意] 给n鹅卵石染色; 有k种颜色可供选择; 问你有没有染色方案; 使得各个堆的鹅卵石里面,第i颜色的鹅卵石的数目的差的绝对值都不大于1 [题解] 把所有的堆 一开始按照石头的数目升序排一遍; 然后顺序处理 对于第一堆石头 1..k,1..k一直重复直到满a[1]个石头; 这以后 每一行直接复制前一行的; 然后开始给多出来的石头染色; 就给他们染成能够染的石子就好; 一开始1..k都还能再染…
题目链接: http://codeforces.com/contest/1187/problem/E 题意: 给出一颗树,找到一个根节点,使所有节点的子节点数之和最大 数据范围: $2 \le n \le 2 \cdot 10^5$ 分析: 最暴力的方法是枚举所有的根节点,计算他们子节点之和,复杂度是$O(n^2)$ 但是可以发现,$a$作为根节点和$b$作为根节点,只有$a,b$节点的子节点数有变化 根的子节点数肯定是$n$,与他交换的点节点数是$x$的话,那么根的子节点数就变成$n-x$,交…
https://codeforces.com/contest/1198/problem/D 原来是dp的思路,而且是每次切成两半向下递归.好像在哪里见过类似的,貌似是紫书的样子. 再想想好像就很显然的样子,并不会出现奇奇怪怪的合并的样子. #include<bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int dp[51][51][51][51]; char g[51][51]; int main() { #if…