Brownie Slicing
通过分析可以发现这是个二分。对于答案ans,如果满足,那么小于的也一定满足,我们要检查大于ans的是否满足
然后就是检查,通过模拟几次,可以发现,确定行,然后检查列就行了。
// Problem: Brownie Slicing
// Contest: NowCoder
// URL: https://ac.nowcoder.com/acm/contest/22353/P
// Memory Limit: 65536 MB
// Time Limit: 2000 ms
// 2022-05-28 18:02:12
//
// Powered by CP Editor (https://cpeditor.org)#include<bits/stdc++.h>
using namespace std;#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,l,r) for(int i=(l);i>=(r);i--)
#define ll long long
#define mset(s,t) memset(s,t,sizeof(t))
#define mcpy(s,t) memcpy(s,t,sizeof(t))
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define mp make_pairtypedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> Vll;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll; const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const double pi = acos(-1.0);
inline ll ksc(ll x,ll y,ll mod)
{ll ans = 0;while (y) {if (y & 1)ans = (ans + x) %mod;y >>= 1;x = (x + x) %mod;}return ans;
}
inline ll qmi (ll a, ll b) {ll ans = 1;while (b) {if (b & 1) ans = ans * a;a = a * a;b >>= 1;}return ans;
}
inline int read () {int x = 0, f = 0;char ch = getchar();while (!isdigit(ch)) f |= (ch=='-'),ch= getchar();while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();return f?-x:x;
}
template<typename T> void print(T x) {if (x < 0) putchar('-'), x = -x;if (x >= 10) print(x/10);putchar(x % 10 + '0');
}
inline ll sub (ll a, ll b) {return ((a - b ) %mod + mod) %mod;
}
inline ll add (ll a, ll b) {return (a + b) %mod;
}
// inline ll inv (ll a) {// return qmi(a, mod - 2);
// }
#define int long long
int n, m;
int a, b;
int s[550][550];bool get (int u, int d, int tar) {int c = 1;int cnt = 0;for (int j = c; j <= m; j ++) {int x1, y1, x2, y2;x2 = d, y2 = j;x1 = u, y1 = c;int sum = s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1];if (sum >= tar) {c = j + 1;cnt ++;}}return cnt >= b;
}
bool check (int tar) {int cnt = 0;int last = 1;for (int i = 1; i <= n; i ++) {if (get(last, i, tar)) {cnt ++;last = i + 1;}}return cnt >= a;
}
void solve() {cin >> n >> m >> a >> b;for (int i = 1; i <= n; i ++) {for (int j = 1; j <= m; j ++){cin >> s[i][j];s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];}}int l = 0, r = 1e9;while (l < r) {int mid = l + r + 1>> 1;if (check(mid))l = mid;else r = mid - 1;}cout << l << endl;
}
signed main () {// ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);int t;t =1;//cin >> t;while (t --) solve();return 0;
}
Brownie Slicing相关推荐
- Brownie Slicing(二分枚举答案)
描述 Bessie has baked a rectangular brownie that can be thought of as an RxC grid (1 <= R <= 500 ...
- 语法入门*算法入门题单
作者:王清楚 链接:https://ac.nowcoder.com/discuss/817596?type=101&order=0&pos=1&page=4&chann ...
- 【新手上路】语法入门算法入门题单
作者:王清楚 链接:[新手上路]语法入门&算法入门题单_ACM竞赛_ACM/CSP/ICPC/CCPC/比赛经验/题解/资讯_牛客竞赛OJ_牛客网 来源:牛客网 介绍:本题单分为语法入门和算法 ...
- 人群场景分析--Slicing Convolutional Neural Network for Crowd Video Understanding
Slicing Convolutional Neural Network for Crowd Video Understanding CVPR2016 http://www.ee.cuhk.edu.h ...
- Python编程基础:第七节 字符串切片String Slicing
第七节 字符串切片String Slicing 前言 实践 前言 我们有时候需要对一个字符串进行切片,取其一部分作为新的字符串进行处理.例如从姓名中分别提取姓和名,从网站域名中提取网站名称等等. 实践 ...
- ValueError: The QuerySet value for an exact lookup must be limited to one result using slicing.
student = Student.objects.filter(student=user) ValueError: The QuerySet value for an exact lookup mu ...
- python学习-元组的复习及进阶使用(iterable、indexing and slicing、sequence unpacking、immutable、named tuple)
文章目录 可迭代的(iterable) 索引和切片(indexing and slicing) 序列解包(sequence unpacking) 不可修改的(immutable) named tupl ...
- Eigen入门之密集矩阵 8 - resharp slicing切片
简介 Eigen还没有提供resharp或者slicing的处理函数,但是,可以使用Map 类来实现这些功能. 实现resharp 操作Resharp及修改Matrix的维度大小,而其系数保持不变.R ...
- xcode5(iOS7)新特性-asset catalog与image slicing
ios7 (xcode5)新特性-asset catalog与image slicing Asset catalog是有一系列的图片,图标,启动画面等组成的. 当创建Xcode5工程时候会常见一个as ...
- 在Python中什么是slicing?
Slicing是一种在有序的对象类型中(数组,元组,字符串)节选某一段的语法. 下面的代码都是在cmd命令行演示的: >>> lst=[11,22,33,44,55] >> ...
最新文章
- 鸽巢原理(The Pigeonhole Principle)(抽屉原理)
- html5--1.18 div元素与布局
- boost::hana::make_optional用法的测试程序
- MySQL之某个表中有近千万数据且CRUD访问缓慢的优化处理
- 三千多天之前我没有编辑完的技术文档
- 云南计算机专业知识真题,2014年云南省事业单位考试专计算机专业知识模拟真题.doc...
- pandas使用dataframe读写mysql数据库
- python用scrapy爬虫豆瓣_Python-用Scrapy爬取豆瓣电影
- spring cloud利用feign和sentinel进行内部或外部远程调用
- 第3节:vue-router如何参数传递
- 我的2012北京LAMP兄弟连
- linux 卸载skype,在Debian 10操作系统上安装和卸载Skype的方法
- 计算机基础知识背诵口诀,字根表口诀怎么快速背-文言文的快速背诵方法4则,附虚词背诵顺口溜...
- 传播正能量——《海南英才》阅读的读后感2200字
- 【高速接口-RapidIO】5、Xilinx RapidIO核例子工程源码分析
- 全球顶尖公司的七大设计理念
- 3GPP TS 23501-g51 中英文对照 | 4.2.5 Data Storage architectures
- 人脸识别(一)调用face++实现人脸检测
- linux系统使用ps,Linux系统ps命令使用教程
- 除了四大“门派”菌,一文了解肠道菌群的其它17个小众“门派”细菌