q次询问,每次询问可以对矩阵某一个值改变(0变1,1变0) 或者是查询子矩阵的最大面积,要求这个这个点在所求子矩阵的边界上,且子矩阵各店中全为1
用up[i][j]表示(i,j)这个点向上能走到的最长高度 若(i,j)为0 则up[i][j]值为0
则每次查询时,从up[i][j]枚举至1作为子矩阵的高度,然后途中分别向左右扩展。若up[i][j - 1] >= up[i][j],则可向左扩展一个单位,答案为(r - l - 1) * 高度
同理,四个方向分别枚举
//#pragma comment(linker, "/STACK:102400000,102400000") //HEAD #include <cstdio> #include <cstring> #include <vector> #include <iostream> #include <algorithm> #include <queue> #include <string> #include <set> #include <stack> #include <map> #include <cmath> #include <cstdlib> using namespace std; //LOOP #define FE(i, a, b) for(int i = (a); i <= (b); ++i) #define FED(i, b, a) for(int i = (b); i>= (a); --i) #define REP(i, N) for(int i = 0; i < (N); ++i) #define CLR(A,value) memset(A,value,sizeof(A)) //STL #define PB push_back //INPUT #define RI(n) scanf("%d", &n) #define RII(n, m) scanf("%d%d", &n, &m) #define RIII(n, m, k) scanf("%d%d%d", &n, &m, &k) #define RS(s) scanf("%s", s) typedef long long LL; const int INF = 0x3f3f3f3f; const int MAXN = 1010; #define FF(i, a, b) for(int i = (a); i < (b); ++i) #define FD(i, b, a) for(int i = (b) - 1; i >= (a); --i) #define CPY(a, b) memcpy(a, b, sizeof(a)) #define FC(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++) #define EQ(a, b) (fabs((a) - (b)) <= 1e-10) #define ALL(c) (c).begin(), (c).end() #define SZ(V) (int)V.size() #define RIV(n, m, k, p) scanf("%d%d%d%d", &n, &m, &k, &p) #define RV(n, m, k, p, q) scanf("%d%d%d%d%d", &n, &m, &k, &p, &q) #define WI(n) printf("%d\n", n) #define WS(s) printf("%s\n", s) typedef vector <int> VI; typedef unsigned long long ULL; const double eps = 1e-10; const LL MOD = 1e9 + 7; const int maxn = 1010; int ipt[maxn][maxn]; int up[maxn][maxn], dwn[maxn][maxn], rht[maxn][maxn], lft[maxn][maxn]; int len[maxn], n, m; void update_col(int y) { FE(i, 1, n) if (ipt[i][y]) up[i][y] = up[i - 1][y] + 1; else up[i][y] = 0; FED(i, n, 1) if (ipt[i][y]) dwn[i][y] = dwn[i + 1][y] + 1; else dwn[i][y] = 0; } void update_row(int x) { FE(j, 1, m) if (ipt[x][j]) lft[x][j] = lft[x][j - 1] + 1; else lft[x][j] = 0; FED(j, m, 1) if (ipt[x][j]) rht[x][j] = rht[x][j + 1] + 1; else rht[x][j] = 0; } int solve(int sta, int hei, int con) { int lm = sta, rm = sta; int ans = 0; for (int h = hei; h >= 1; h--) { while (lm >= 1 && len[lm] >= h) lm--; while (rm <= con && len[rm] >= h) rm++; ans = max(ans, h * (rm - lm - 1)); } return ans; } int main() { //freopen("0.txt", "r", stdin); int q, x, y, op; cin >> n >> m >> q; FE(i, 1, n) FE(j, 1, m) RI(ipt[i][j]); FE(i, 1, n) update_row(i); FE(j, 1, m) update_col(j); while (q--) { RIII(op, x, y); if (op == 1) { ipt[x][y] ^= 1; update_row(x); update_col(y); // cout << "UP " << endl; // FE(i, 1, n) { // FE(j, 1, m) // cout << up[i][j] << ' '; // cout <<endl; // } // cout << "----" << endl; // cout << "right " << endl; // FE(i, 1, n) { // FE(j, 1, m) // cout << rht[i][j] << ' '; // cout <<endl; // } // cout << "----" << endl; } else { int ans = 0; FE(j, 1, m) len[j] = up[x][j]; ans = max(ans, solve(y, len[y], m)); FE(j, 1, m) len[j] = dwn[x][j]; ans = max(ans, solve(y, len[y], m)); FE(i, 1, n) len[i] = lft[i][y]; ans = max(ans, solve(x, len[x], n)); FE(i, 1, n) len[i] = rht[i][y]; ans = max(ans, solve(x, len[x], n)); WI(ans); } } return 0; }
以上就是codeforces248(div1) B Nanami's Digital Board的内容,更多相关内容请关注PHP中文网(www.php.cn)!

WebDevelovermentReliesonHtml,CSS和JavaScript:1)HTMLStructuresContent,2)CSSStyleSIT和3)JavaScriptAddSstractivity,形成thebasisofmodernWebemodernWebExexperiences。

HTML的作用是通过标签和属性定义网页的结构和内容。1.HTML通过到、等标签组织内容,使其易于阅读和理解。2.使用语义化标签如、等增强可访问性和SEO。3.优化HTML代码可以提高网页加载速度和用户体验。

htmlisaspecifictypefodyfocusedonstructuringwebcontent,而“代码” badlyLyCludEslanguagesLikeLikejavascriptandPytyPythonForFunctionality.1)htmldefineswebpagertuctureduseTags.2)“代码”代码“ code” code code code codeSpassSesseseseseseseseAwiderRangeLangeLangeforLageforLogageforLogicIctInterract

HTML、CSS和JavaScript是Web开发的三大支柱。1.HTML定义网页结构,使用标签如、等。2.CSS控制网页样式,使用选择器和属性如color、font-size等。3.JavaScript实现动态效果和交互,通过事件监听和DOM操作。

HTML定义网页结构,CSS负责样式和布局,JavaScript赋予动态交互。三者在网页开发中各司其职,共同构建丰富多彩的网站。

HTML适合初学者学习,因为它简单易学且能快速看到成果。1)HTML的学习曲线平缓,易于上手。2)只需掌握基本标签即可开始创建网页。3)灵活性高,可与CSS和JavaScript结合使用。4)丰富的学习资源和现代工具支持学习过程。

AnexampleOfAstartingTaginHtmlis,beginSaparagraph.startingTagSareEssentialInhtmlastheyInitiateEllements,defiteTheeTheErtypes,andarecrucialforsstructuringwebpages wepages webpages andConstructingthedom。

如何设计菜单中的虚线分割效果?在设计菜单时,菜名和价格的左右对齐通常不难实现,但中间的虚线或点如何...


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

Atom编辑器mac版下载
最流行的的开源编辑器

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

SublimeText3 Linux新版
SublimeText3 Linux最新版

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能