搞了好久,发现自己是想法没错的,错在输入,必须是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. P1314 聪明的质监员 二分答案

    这个题我第一反应是线段树(雾),然后看了一眼题解之后就后悔了...前缀和...然后二分答案,然后就没有然后了. 题干: 小T 是一名质量监督员,最近负责检验一批矿产的质量.这批矿产共有 nnn 个矿石 ...

  2. 多线程编程和Java网络编程

    1. 线程概述 多任务处理有两种类型:基于进程.基于线程(进程是指一种“自包容”的运行程序,有自己的地址空间; 线程是进程内部单一的一个顺序控制流) 基于进程的特点是允许计算机同时运行两个或更多的程序 ...

  3. 原生JS---5

    原生js学习笔记5——BOM操作 什么是BOM BOM:Browser Object Model 是浏览器对象模型,浏览器对象模型提供了独立与内容的.可以与浏览器窗口进行互动的对象结构,BOM由多个对 ...

  4. Python27天 反射 ,isinstance与ssubclass 内置方法

    所学内容 反射 1.hasattr ( 判断一个属性在对象里有没有 ) -------------------- [对象,字符串属性]本质是:# 判断 ' name ' in obj.__dict__ ...

  5. SpringBoot + MyBatis(注解版),常用的SQL方法

    一.新建项目及配置 1.1 新建一个SpringBoot项目,并在pom.xml下加入以下代码 <dependency> <groupId>org.mybatis.spring ...

  6. Spring Boot (5) Spring Boot配置详解

    application.properties application.properties是spring boot默认的配置文件,spring boot默认会在以下两个路径搜索并加载这个文件 src\ ...

  7. Lua eval实现

    因为loadstring总是在全局环境中编译它的串,所以编译出的函数访问的变量是全局变量.为了避免污染全局环境我们需要用setfenv修改函数的环境 function eval(equation, v ...

  8. java Queue中 remove/poll, add/offer, element/peek区别

    offer,add区别: 一些队列有大小限制,因此如果想在一个满的队列中加入一个新项,多出的项就会被拒绝. 这时新的 offer 方法就可以起作用了.它不是对调用 add() 方法抛出一个 unche ...

  9. [hihocoder][Offer收割]编程练习赛60

    hohahola #pragma comment(linker, "/STACK:102400000,102400000") #include<stdio.h> #in ...

  10. ubuntu 14.04安装x11VNC

    环境:Ubuntu 14.04, 1)安装x11vnc: sudo apt-get install x11vnc 2)设置VNC的连接密码: x11vnc -storepasswd Enter VNC ...