题目大意:给一个点阵,其中有的地方没有点,操作是去掉某个点,并询问当前点阵中最大的正方形

若没有修改的话,裸dp

加上修改,可以考虑时光倒流,这样答案就是递增的

可以用并查集维护点的连通性,O^2的

#include<bits/stdc++.h>
using namespace std;
#define maxn 2010
inline void MIN(int &a,int b){if(a>b)a=b;}
inline void MAX(int &a,int b){if(a<b)a=b;}
int n,m,q,sz;
int f[maxn][maxn],u[maxn][maxn],lg[maxn],rg[maxn],qx[maxn],qy[maxn],ans[maxn];
char s[maxn][maxn];
struct line{
int f[maxn];
int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
}l[maxn],r[maxn];
void del(int x,int y){
l[x].f[y]=l[x].find(y-);
r[x].f[y]=r[x].find(y+);
}
int main(){
scanf("%d%d%d",&n,&m,&q);
for(int i=;i<=n;++i)
for(int j=;j<=m+;++j){
l[i].f[j]=j;
r[i].f[j]=j;
u[i][j]=i;
}
for(int i=;i<=n;++i)scanf("%s",s[i]+);
for(int i=;i<=q;++i)scanf("%d%d",&qx[i],&qy[i]),s[qx[i]][qy[i]]='X';
for(int i=;i<=n;++i)
for(int j=;j<=m;++j)
if(s[i][j]=='.')
del(i,j);
for(int i=;i<=n;++i)
for(int j=;j<=m;++j)
if(s[i][j]=='.'){
u[i][j]=u[i-][j];
f[i][j]=min(f[i-][j-]+,min(i-u[i][j],j-l[i].find(j)));
MAX(sz,f[i][j]);
}
for(int v=q;v;--v){
ans[v]=sz;
del(qx[v],qy[v]);
for(int i=;i<=n;++i){
lg[i]=qy[v]-l[i].find(qy[v]);
rg[i]=r[i].find(qy[v])-qy[v];
}
for(int i=qx[v]-;i>=;--i)MIN(lg[i],lg[i+]),MIN(rg[i],rg[i+]);
for(int i=qx[v]+;i<=n;++i)MIN(lg[i],lg[i-]),MIN(rg[i],rg[i-]);
for(int i=;i<=qx[v];++i)
while(i+sz<=n&&min(rg[i],rg[i+sz])+min(lg[i],lg[i+sz])->sz)
++sz;
}
for(int i=;i<=q;++i)
printf("%d\n",ans[i]);
return ;
}

codeforces480E Parking Lot的更多相关文章

  1. [LintCode] Parking Lot 停车场问题

    Design a parking lot. see CC150 OO Design for details.1) n levels, each level has m rows of spots an ...

  2. [CareerCup] 8.4 Parking Lot 停车场问题

    8.4 Design a parking lot using object-oriented principles. LintCode上的原题,请参见我的另一篇博客Parking Lot 停车场问题. ...

  3. Codeforces 46D Parking Lot

    传送门 D. Parking Lot time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  4. Codeforces Round #135 (Div. 2) E. Parking Lot 线段数区间合并

    E. Parking Lot time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  5. Amazon Interview Question: Design an OO parking lot

    Design an OO parking lot. What classes and functions will it have. It should say, full, empty and al ...

  6. HDOJ(HDU) 1673 Optimal Parking

    Problem Description When shopping on Long Street, Michael usually parks his car at some random locat ...

  7. Lesson 28 No parking

    Text Jasper White is one of those rare people who believes in ancient myths. He has just bought a ne ...

  8. [PA2014]Parking

    [PA2014]Parking 题目大意: 停车场是一个宽度为\(w(w\le10^9)\)的矩形.我们以其左下角顶点为原点,坐标轴平行于矩形的边,建立直角坐标系.停车场很长,我们可以认为它一直向右边 ...

  9. Codeforces 219E Parking Lot 线段树

    Parking Lot 线段树区间合并一下, 求当前要占的位置, 不包括两端点的写起来方便一点. #include<bits/stdc++.h> #define LL long long ...

随机推荐

  1. 【转载】Android app 安全测试调研及执行

    本文来源于:http://testerhome.com/topics/2209 一.通过在线工具进行测试 1.腾讯金刚审计系统http://service.security.tencent.com 优 ...

  2. HDU4067 Random Maze(最小费用最大流)

    题目大概说,给一张图,删除其中一些单向边,使起点s出度比入度多1,终点t入度比出度多1,其他点出度等于入度.其中删除边的费用是bi,保留边的费用是ai,问完成要求最小的费用是多少. 一开始我想到和混合 ...

  3. js事件绑定细节说明

    javascript绑定事件: 经常用jQuery去写,时间长了对原生态的js事件绑定的知识会慢慢淡化或者遗忘了,必须翻出来再次总结,今天再次把js原生态事件的处理做个总结. 从最初开始,谁刚接触ja ...

  4. POJ 1014 Dividing(多重背包)

    Dividing   Description Marsha and Bill own a collection of marbles. They want to split the collectio ...

  5. Poj1852

    题目求的是:所有蚂蚁用最短时间从木棍上走下来的最大值(也就是最后一个蚂蚁什么时候走下来的) 所有蚂蚁中,用时最长的情况 PS:根本不用考虑两只蚂蚁相遇又折返的情况(可以直接认为是他两互不影响的走) # ...

  6. CF#335 Lazy Student

    Lazy Student time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  7. ccc 模拟重力 正太分布

    ball.js cc.Class({ extends: cc.Component, properties: { x_vel:{ default:0 }, y_vel:{ default:0 }, gr ...

  8. BZOJ4356 : Ceoi2014 Wall

    求出左上角到每个需要保护的点左上角的最短路树,那么最优解一定圈住了它们. 然后将每个点拆成四个点,四个点之间如果没跨越最短路树的树边,那就连0权边. 每个需要保护的点四周4个点都不可通行,求出最短路即 ...

  9. BZOJ3551 : [ONTAK2010]Peaks加强版

    首先强制在线的话,肯定是不能再离线排序+平衡树启发式合并了. 这回要用的是线段树合并,每次把两棵线段树合并,总复杂度为$O(n\log n)$ 预处理: 把边按权值从小到大排序,依次加边, 对于边(x ...

  10. [转]Maven实现直接部署Web项目到Tomcat7

    From:http://my.oschina.net/angel243/blog/178554 http://yuandingjiema.iteye.com/blog/1752544 以前在项目中很少 ...