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

若没有修改的话,裸dp

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

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

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define maxn 2010
  4. inline void MIN(int &a,int b){if(a>b)a=b;}
  5. inline void MAX(int &a,int b){if(a<b)a=b;}
  6. int n,m,q,sz;
  7. int f[maxn][maxn],u[maxn][maxn],lg[maxn],rg[maxn],qx[maxn],qy[maxn],ans[maxn];
  8. char s[maxn][maxn];
  9. struct line{
  10. int f[maxn];
  11. int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
  12. }l[maxn],r[maxn];
  13. void del(int x,int y){
  14. l[x].f[y]=l[x].find(y-);
  15. r[x].f[y]=r[x].find(y+);
  16. }
  17. int main(){
  18. scanf("%d%d%d",&n,&m,&q);
  19. for(int i=;i<=n;++i)
  20. for(int j=;j<=m+;++j){
  21. l[i].f[j]=j;
  22. r[i].f[j]=j;
  23. u[i][j]=i;
  24. }
  25. for(int i=;i<=n;++i)scanf("%s",s[i]+);
  26. for(int i=;i<=q;++i)scanf("%d%d",&qx[i],&qy[i]),s[qx[i]][qy[i]]='X';
  27. for(int i=;i<=n;++i)
  28. for(int j=;j<=m;++j)
  29. if(s[i][j]=='.')
  30. del(i,j);
  31. for(int i=;i<=n;++i)
  32. for(int j=;j<=m;++j)
  33. if(s[i][j]=='.'){
  34. u[i][j]=u[i-][j];
  35. f[i][j]=min(f[i-][j-]+,min(i-u[i][j],j-l[i].find(j)));
  36. MAX(sz,f[i][j]);
  37. }
  38. for(int v=q;v;--v){
  39. ans[v]=sz;
  40. del(qx[v],qy[v]);
  41. for(int i=;i<=n;++i){
  42. lg[i]=qy[v]-l[i].find(qy[v]);
  43. rg[i]=r[i].find(qy[v])-qy[v];
  44. }
  45. for(int i=qx[v]-;i>=;--i)MIN(lg[i],lg[i+]),MIN(rg[i],rg[i+]);
  46. for(int i=qx[v]+;i<=n;++i)MIN(lg[i],lg[i-]),MIN(rg[i],rg[i-]);
  47. for(int i=;i<=qx[v];++i)
  48. while(i+sz<=n&&min(rg[i],rg[i+sz])+min(lg[i],lg[i+sz])->sz)
  49. ++sz;
  50. }
  51. for(int i=;i<=q;++i)
  52. printf("%d\n",ans[i]);
  53. return ;
  54. }

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. PHP之数据类型

    1.PHP字符串(String):一个字符串是一串字符的序列,就像"Hello world!":可以将任何文本放在单引号和双引号中: <?php $x="Hello ...

  2. C#性能测试方法

    用 System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); for (int i ...

  3. soapui中文操作手册(七)----Web Service Sample Project

    REST推理 这份简短的教程将引导您完成架构推断功能. 我们将创建一个新的项目,并添加一个REST服务,而初始WADL文件启动了. 发送请求后,我们就可以使用响应来构建我们的架构. 演示请求 为了演示 ...

  4. HDU 3090 (贪心)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3090 题目大意:一共n段路.每段路每千米都会被抢劫一定数量,可以雇佣武士护卫m千米.问最少被抢劫数量 ...

  5. weblogic应用平台常见问题小结

    http://blog.sina.com.cn/s/blog_4aa08b7c010004yc.html 1.当以另一用户登录系统后,系统却显示的是前一用户的身份.    这是由于页面信息没有刷新造成 ...

  6. Codeforces Round #249 (Div. 2) A - Queue on Bus Stop

    水题 #include <iostream> #include <vector> #include <algorithm> using namespace std; ...

  7. Visiual Studio2012 CLR20r3问题

    看到有更新,习惯性的点了,升级到Visiual Studio Ultimate 2012 Update 1,并且按照提升重启了电脑.因为昨天太晚,也没验证.尽早打开VS,结果直接Crash.错误如下: ...

  8. BestCoder Round #77

    T1 xiaoxin juju needs help 计算组合数然后多重集排列乱搞,注意判无解情况(TM我就判错然后FST了). #include<cstdio> #include< ...

  9. 彩色照片转换为黑白照片(Color image converted to black and white picture)

    This blog will be talking about the color image converted to black and white picture. The project st ...

  10. qt编译常见错误

    一.fatal error: QWidget: 没有那个文件或目录 类似于找不到文件目录的,在.pro文件中添加 QT +=\ widgets 类似就可以编译通过