q times of questioning, each query can change a certain value of the matrix (0 to 1, 1 to 0) or query the maximum area of the submatrix, requiring this point to be in the desired submatrix on the boundary of , and all stores in the sub-matrix are 1
Use up[i][j] to represent the longest height that point (i,j) can go upward if (i,j ) is 0, then the value of up[i][j] is 0
Similarly, maintain down,left, rightarray
>Every time you query, enumerate from up[i][j] to 1 as the height of the submatrix, and then expand to the left and right along the way. If up[i][j - 1] >= up[i][j], you can expand one unit to the left, and the answer is (r - l - 1) * height
Similarly, four Each direction is enumerated separately
//#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; }
The above is the content of codeforces248(div1) B Nanami's Digital Board. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

A consistent HTML encoding style is important because it improves the readability, maintainability and efficiency of the code. 1) Use lowercase tags and attributes, 2) Keep consistent indentation, 3) Select and stick to single or double quotes, 4) Avoid mixing different styles in projects, 5) Use automation tools such as Prettier or ESLint to ensure consistency in styles.

Solution to implement multi-project carousel in Bootstrap4 Implementing multi-project carousel in Bootstrap4 is not an easy task. Although Bootstrap...

How to achieve the effect of mouse scrolling event penetration? When we browse the web, we often encounter some special interaction designs. For example, on deepseek official website, �...

The default playback control style of HTML video cannot be modified directly through CSS. 1. Create custom controls using JavaScript. 2. Beautify these controls through CSS. 3. Consider compatibility, user experience and performance, using libraries such as Video.js or Plyr can simplify the process.

Potential problems with using native select on mobile phones When developing mobile applications, we often encounter the need for selecting boxes. Normally, developers...

What are the disadvantages of using native select on your phone? When developing applications on mobile devices, it is very important to choose the right UI components. Many developers...

Use Three.js and Octree to optimize collision handling of third-person roaming in the room. Use Octree in Three.js to implement third-person roaming in the room and add collisions...

Issues with native select on mobile phones When developing applications on mobile devices, we often encounter scenarios where users need to make choices. Although native sel...


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
