搞了好久,发现自己是想法没错的,错在输入,必须是while(){}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std; struct Water{
int px,py;
int dirx,diry;
Water(){}
Water(int x,int y,int dx,int dy){px=x,py=y;dirx=dx,diry=dy;}
}que[];
struct Posover{
int x,y;
Posover(int tx,int ty){x=tx,y=ty;}
Posover(){}
};
vector<Posover>vec;
int head,tail; int map[][]; void work(int x,int y){
map[x-][y-]++;
if(map[x-][y-]>=){
map[x-][y-]=;
que[tail++]=Water(x-,y-,,-);
que[tail++]=Water(x-,y-,,);
que[tail++]=Water(x-,y-,,);
que[tail++]=Water(x-,y-,-,);
}
int sz;
vec.clear();
int cnt=;
while(head<tail){
sz=tail-head;
cnt++;
while(sz--){
int tx=que[head].px+que[head].dirx;
int ty=que[head].py+que[head].diry;
if(tx>=&&tx<=&&ty>=&&ty<=){
if(map[tx][ty]>){
map[tx][ty]++;
if(map[tx][ty]==){
vec.push_back(Posover(tx,ty));
}
}
else{
que[tail++]=Water(tx,ty,que[head].dirx,que[head].diry);
}
}
head++;
}
int vsz=vec.size();
for(int i=;i<vsz;i++){
map[vec[i].x][vec[i].y]=;
que[tail++]=Water(vec[i].x,vec[i].y,,);
que[tail++]=Water(vec[i].x,vec[i].y,,-);
que[tail++]=Water(vec[i].x,vec[i].y,,);
que[tail++]=Water(vec[i].x,vec[i].y,-,);
}
vec.clear();
}
// cout<<cnt<<endl;
} int main(){
while(scanf("%d",&map[][])!=EOF){
int j;
for(int i=;i<;i++){
for(i==?j=:j=;j<;j++)
scanf("%d",&map[i][j]);
}
int nop,x,y;
scanf("%d",&nop);
while(nop--){
tail=head=;
scanf("%d%d",&x,&y);
if(x>=&&x<=&&y>=&&y<=)
work(x,y);
}
for(int i=;i<;i++){
printf("%d",map[i][]);
for(int j=;j<;j++){
printf(" %d",map[i][j]);
}
printf("\n");
}
printf("\n");
}
return ;
}

HDU 4527的更多相关文章

  1. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  2. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  3. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  4. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  5. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  6. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

  7. hdu 4481 Time travel(高斯求期望)(转)

    (转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...

  8. HDU 3791二叉搜索树解题(解题报告)

    1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/articl ...

  9. hdu 4329

    problem:http://acm.hdu.edu.cn/showproblem.php?pid=4329 题意:模拟  a.     p(r)=   R'/i   rel(r)=(1||0)  R ...

随机推荐

  1. B1041 [HAOI2008]圆上的整点 数学

    这个题一开始看着没什么思路,但是一看题解就明白了不少,主要是数学证明,代码很好写. 贴个网址: hzwer 题干: 题目描述 求一个给定的圆(x^+y^=r^),在圆周上有多少个点的坐标是整数. 输入 ...

  2. iOS社会化分享(干货)

    一.苹果原生集成的社会化分享 1.哪些平台 (1)Twitter (2)FaceBook (3)Flickr (4)Vimeo (5)新浪微博  :iOS6 (6)腾讯微博 : iOS7 2.框架 : ...

  3. 77.招聘信息管理 EXTJS 页面

    1. <%@ page language="java" import="java.util.*" pageEncoding="UTF-8&quo ...

  4. sql小计合计

    转自:http://www.jb51.net/article/18860.htm 这里介绍sql server2005里面的一个使用实例: CREATE TABLE tb(province nvarc ...

  5. Python 36 死锁现象和递归锁、信号量、Event事件、线程queue

    一:死锁现象和递归锁 所谓死锁: 是指两个或两个以上的进程或线程在执行过程中,因争夺资源而造成的一种互相等待的现象,若无外力作用,它们都将无法推进下去.此时称系统处于死锁状态或系统产生了死锁,这些永远 ...

  6. BZOJ 4514 费用流

    思路: 懒得写了 http://blog.csdn.net/werkeytom_ftd/article/details/51277482 //By SiriusRen #include <que ...

  7. B - Magnets

    Problem description Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't ...

  8. Django中的bug总结

    1.插入数据库的时候,少写一个字段.ps:看准数据库的字段,是不是非空,是不是外键. 2.当同一个视图中需要连续操作两个数据表时,先看好两个表的外键之间的关系,再进行操作表.比如:一个订单表order ...

  9. Eclipse之调试代码和返回

    编写代码时,经常会遇到各种莫名其妙的问题,为了检测程序是哪里出现问题,我们通过断点调试来判断哪一步出错 一.断点 在需要断点的地方,在左侧双击鼠标设置断点,可设置多个 去掉断点:在断点上双击一下,没有 ...

  10. Typeclassopedia 阅读笔记:导言与 Functor

    Typeclassopedia 阅读笔记 本文是对介绍 Haskell 中类型类(type classes)的文档 Typeclassopedia 的阅读笔记和简短总结,包含此文档中重要的知识点.读者 ...