CF 22B. Bargaining Table】的更多相关文章

水题.好久没有写过优化搜索题了. #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; ][]; ][]; ][]; int judge(int rx,int ry,int lx,int ly) { int i,j; for(i = lx;i <= rx;i ++) { for(j = ly;j <= ry;j…
B. Bargaining Table time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bob wants to put a new bargaining table in his office. To do so he measured the office room thoroughly and drew its plan…
http://www.codeforces.com/problemset/problem/22/B 题意:求出n*m的方格图中全是0的矩阵的最大周长 思路:枚举 #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> #include<iostream> ][],h[][]; ]; int read(){ ,f=;char ch=getchar(); ;ch=g…
题目很好理解,问你的是在所给的图中周长最长的矩形是多长嗯用坐标(x1, y1, x2, y2)表示一个矩形,暴力图中所有矩形易得递推式:(x1, y1, x2, y2)为矩形的充要条件为: (x1, y1, x2, y2) 和 (x1, y1, x2, y2)为合法矩形,即全部为0 Point(x2, y2) 为 0 当然对X1 == X2这种特殊情况需要特殊判断一下. Source Code: //#pragma comment(linker, "/STACK:16777216")…
Bargaining Table time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bob wants to put a new bargaining table in his office. To do so he measured the office room thoroughly and drew its plan: B…
题目传送门 /* 题意:求最大矩形(全0)的面积 暴力/dp:每对一个0查看它左下的最大矩形面积,更新ans 注意:是字符串,没用空格,好事多磨,WA了多少次才发现:( 详细解释:http://www.cnblogs.com/cszlg/p/3217478.html */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std…
题目链接 很多小的细节都没想到... #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; ]; ]; int main() { ,j; scanf("%d",&n); ;i < n;i ++) { scanf("%d",&p[i]); ) flag = ; }…
传送门 简单的中国剩余定理练习. 首先行数一定是$lcm$,然后只要确定最小的列数就能判定解合不合法了. 我们可以得到线性模方程组: $y \equiv 0 \pmod{a_1}$ $y+1 \equiv 0 \pmod {a_2}$ $y+2 \equiv 0 \pmod {a_3}$ $...$ $y+n \equiv 0 \pmod {a_{n+1}}$ 然后CRT搞出来一组解,暴力判判就OK了. //CF338D //by Cydiater //2017.2.20 #include &l…
用FWT优化计算. 首先发现行数很小,想到一个暴力的方法,就是以一个二进制位$0$表示这一行不翻转而二进制位$1$表示这一行翻转,然后$2^n$枚举出所有行的翻转情况,再$O(m)$计算所有的结果. 用$a_i$表示第$i$列的原来的情况,有计算式: $$ans_s = \sum_{i = 1}^{m}(a_i \oplus s) * min(bit_{a_i \oplus  s}, n - bit_{a_i \oplus s})$$ 这里的$bit_i$表示$i$的二进制表示中$1$的个数.…
前言 从后往前刷 update 新增 \(\text{\color{red}{Mark}}\) 标记功能,有一定难度的题标记为 \(\text{\color{red}{红}}\) 色. 题单 (刷过的题就会登记在上面) 2B The least round way 只有 \(2^a*5^b\) 尾随'\(0\)'的个数为 \(\text{min}(a,b)\),dp一遍就好了 4D Mysterious Present 5C Longest Regular Bracket Sequence [C…