HDU 4527
搞了好久,发现自己是想法没错的,错在输入,必须是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的更多相关文章
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- hdu 4481 Time travel(高斯求期望)(转)
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...
- HDU 3791二叉搜索树解题(解题报告)
1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/articl ...
- hdu 4329
problem:http://acm.hdu.edu.cn/showproblem.php?pid=4329 题意:模拟 a. p(r)= R'/i rel(r)=(1||0) R ...
随机推荐
- class--类①
原来看其他人的代码,发现有好多class之类的语句,当时没太注意.可后来,我觉得应该有学习新知识的必要了. 类定义是以关键字 class 开头,后跟类的名称.类的主体是包含在一对花括号中.类定义后必须 ...
- js软键盘
<<!DOCTYPE html><html><head> <title></title></head><body& ...
- 题解报告:hdu 1850 Being a Good Boy in Spring Festival(尼姆博弈)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1850 Problem Description 一年在外 父母时刻牵挂春节回家 你能做几天好孩子吗寒假里 ...
- Django html页面 'ascii' codec can't encode characters in position 8-10: ordinal not
用Django开发的页面,之前用的是python3.X,后来又换成python2.X后各种报错,编码问题,于是在所有python文件开头加了编码:#coding=utf-8 但是后来发现,有些文件加了 ...
- idea使用maven搭建ssm框架实现登陆商品增删改查
创建项目->maven->webapp->输入坐标->完成. pom.xml <project xmlns="http://maven.apache.org/P ...
- ★Java语法(六)——————————分支语句
1. if 语句 格式用法: if(布尔表达式) { 语句: } 2. if……else 语句 格式用法: if(表达式) { 语句1: } else { 语句2: } 3.if……else i ...
- 【Oracle】详解10053事件
借助Oracle的10053事件event,我们可以监控到CBO对SQL进行成本计算和路径选择的过程和方法. 10053事件有两个级别: Level 2:2级是1级的一个子集,它包含以下内容: Col ...
- PCL:描述三维离散点的ROPS特征(Code)
前言: 三维点云为三维欧式空间点的集合.对点云的形状描述若使用局部特征,则可分为两种:固定世界坐标系的局部描述和寻找局部主方向的局部描述,ROPS特征为寻找局部主方向的特征描述. 1.寻找主方向(对X ...
- excel 打开显示安装office自定义项 安装期间出错的解决方法
用管理员身份运行EXCEL,转到COM加载项,删除对应加载项,即可. 注:上下两张图中的加载项信息不一致,仅作图示参考.
- BZOJ 4999: This Problem Is Too Simple! DFS序+LCA+树状数组+离线
Code: #include<bits/stdc++.h> #define setIO(s) freopen(s".in","r",stdin) , ...