search
HomeWeb Front-endHTML Tutorialcodeforces248(div1) B Nanami's Digital Board

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] << &#39; &#39;;
//                    cout <<endl;
//            }
//            cout << "----" << endl;
//            cout << "right  " << endl;
//            FE(i, 1, n) {
//                FE(j, 1, m)
//                    cout << rht[i][j] << &#39; &#39;;
//                    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)!


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?Mar 04, 2025 pm 12:32 PM

The official account web page update cache, this thing is simple and simple, and it is complicated enough to drink a pot of it. You worked hard to update the official account article, but the user still opened the old version. Who can bear the taste? In this article, let’s take a look at the twists and turns behind this and how to solve this problem gracefully. After reading it, you can easily deal with various caching problems, allowing your users to always experience the freshest content. Let’s talk about the basics first. To put it bluntly, in order to improve access speed, the browser or server stores some static resources (such as pictures, CSS, JS) or page content. Next time you access it, you can directly retrieve it from the cache without having to download it again, and it is naturally fast. But this thing is also a double-edged sword. The new version is online,

How to efficiently add stroke effects to PNG images on web pages?How to efficiently add stroke effects to PNG images on web pages?Mar 04, 2025 pm 02:39 PM

This article demonstrates efficient PNG border addition to webpages using CSS. It argues that CSS offers superior performance compared to JavaScript or libraries, detailing how to adjust border width, style, and color for subtle or prominent effect

How do I use HTML5 form validation attributes to validate user input?How do I use HTML5 form validation attributes to validate user input?Mar 17, 2025 pm 12:27 PM

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

What is the purpose of the <datalist> element?What is the purpose of the <datalist> element?Mar 21, 2025 pm 12:33 PM

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the purpose of the <progress> element?What is the purpose of the <progress> element?Mar 21, 2025 pm 12:34 PM

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

What is the purpose of the <meter> element?What is the purpose of the <meter> element?Mar 21, 2025 pm 12:35 PM

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

What are the best practices for cross-browser compatibility in HTML5?What are the best practices for cross-browser compatibility in HTML5?Mar 17, 2025 pm 12:20 PM

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

What is the purpose of the <iframe> tag? What are the security considerations when using it?What is the purpose of the <iframe> tag? What are the security considerations when using it?Mar 20, 2025 pm 06:05 PM

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MantisBT

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 Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.