CODEFORCES480E Parking IoT

Source: Internet
Author: User

Title: To a lattice, where there is no point, the operation is to remove a point, and ask the current lattice of the largest square

If not modified, the bare DP

Plus the changes, you can consider the time reversal, so the answer is incremental

can use and check the connectivity of the maintenance point, o^2

#include <bits/stdc++.h>using namespacestd;#defineMAXN 2010inlinevoidMIN (int&a,intb) {if(a>b) a=b;} InlinevoidMAX (int&a,intb) {if(a<b) a=b;}intN,m,q,sz;intF[MAXN][MAXN],U[MAXN][MAXN],LG[MAXN],RG[MAXN],QX[MAXN],QY[MAXN],ANS[MAXN];CharS[MAXN][MAXN];structline{intF[MAXN]; intFindintx) {returnf[x]==x?x:f[x]=find (F[x]);}} L[MAXN],R[MAXN];voidDelintXinty) {L[x].f[y]=l[x].find (y1); R[x].f[y]=r[x].find (y+1);}intMain () {scanf ("%d%d%d",&n,&m,&q);  for(intI=1; i<=n;++i) for(intj=1; j<=m+1;++j) {L[i].f[j]=J; R[I].F[J]=J; U[I][J]=i; }     for(intI=1; i<=n;++i) scanf ("%s", s[i]+1);  for(intI=1; i<=q;++i) scanf ("%d%d", &qx[i],&qy[i]), s[qx[i]][qy[i]]='X';  for(intI=1; i<=n;++i) for(intj=1; j<=m;++j)if(s[i][j]=='.') del (I,J);  for(intI=1; i<=n;++i) for(intj=1; j<=m;++j)if(s[i][j]=='.') {U[i][j]=u[i-1][j]; F[I][J]=min (f[i-1][j-1]+1, Min (i-u[i][j],j-L[i].find (j)));            MAX (Sz,f[i][j]); }     for(intv=q;v;--v) {Ans[v]=sz;        Del (Qx[v],qy[v]);  for(intI=1; i<=n;++i) {Lg[i]=qy[v]-L[i].find (Qy[v]); Rg[i]=r[i].find (Qy[v])-Qy[v]; }         for(inti=qx[v]-1; i>=1; i) MIN (lg[i],lg[i+1]), MIN (rg[i],rg[i+1]);  for(inti=qx[v]+1; i<=n;++i) MIN (lg[i],lg[i-1]), MIN (rg[i],rg[i-1]);  for(intI=1; i<=qx[v];++i) while(I+sz<=n&&min (Rg[i],rg[i+sz]) +min (Lg[i],lg[i+sz])-1>sz)++sz; }     for(intI=1; i<=q;++i) printf ("%d\n", Ans[i]); return 0;}
View Code

CODEFORCES480E Parking IoT

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.