搞了好久,发现自己是想法没错的,错在输入,必须是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. class--类②

    定义 C++ 对象 类提供了对象的蓝图,所以基本上,对象是根据类来创建的.声明类的对象,就像声明基本类型的变量一样.下面的语句声明了类 Box 的两个对象: Box Box1; // 声明 Box1, ...

  2. PCB MS SQL 排序应用---相邻数据且相同合并处理

    这是一个很有趣SQL数据处理应用,具体需求如下 ERP需要工程将物料编码相邻的编码合并求和BOM用量,巧妙的用到了已有排序号与分组排序号之间的差值求解 示例: 原数据: 要求转换: 实际转换后数据: ...

  3. A Round Peg in a Ground Hole(圆与凸包)

    http://poj.org/problem?id=1584 题意:判断所给的点能不能形成凸包,并判断所给的圆是否在凸包内. 改了好几天的一个题,今天才发现是输入顺序弄错了,办过的最脑残的事情..sa ...

  4. tpshop编辑框中上传图片过大变模糊

    tpshop编辑框中上传图片过大变模糊 图片超过2500的高就会变模糊 设置最大的高度修改一下

  5. JavaScript是按值传递还是按引用传递?

    JavaScript是按值传递的,但是要分情况才知道传递之后原来的值会不会变,不然会出现你想都想不出来的bug 一.按值传递--元类型输入tip:元类型( number, string, boolea ...

  6. mybatis parameterType报错:There is no getter for property named 'xxx' in 'class java.lang.String'

    方法1: 当parameterType = "java.lang.String" 的时候,参数读取的时候必须为 _parameter 方法2: 在dao层的时候,设置一下参数,此方 ...

  7. 自学Python九 爬虫实战二(美图福利)

    作为一个新世纪有思想有文化有道德时刻准备着的屌丝男青年,在现在这样一个社会中,心疼我大慢播抵制大百度的前提下,没事儿上上网逛逛YY看看斗鱼翻翻美女图片那是必不可少的,可是美图虽多翻页费劲!今天我们就搞 ...

  8. SQLServer2008 关于Group by

    如果我们想知道每个国家有多少种水果,那么我们可以通过如下SQL语句来完成: SELECT COUNT(*) FruitName AS 水果种类, ProductPlace AS 出产国 FROM T_ ...

  9. swift-delegate(代理)或者block传值

    1:delegate或者block传值 import UIKit class ViewController: UIViewController,TestDelegatePassValueDelegat ...

  10. https 结合使用 对称加密和非对称加密

    (一)对称加密(Symmetric Cryptography) ---共享密钥加密 对称加密是最快速.最简单的一种加密方式,加密(encryption)与解密(decryption)用的是同样的密钥( ...