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 ...
随机推荐
- SQL 导出表数据存储过程
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- ...
- 更新svn时出错,大概的意思是项目被锁定了
- ”W: GPG 错误:http://ppa.launchpad.net lucid Release: 由于没有公钥,无法验证下列签名:“的问题
在安装更新时,即在运行,命令行sudo apt-get update 或者运行更新管理器的时候,出现如下错误: W: GPG 错误:http://ppa.launchpad.net lucid Rel ...
- 树莓派-基于raspistill实现定时拍照
raspistill 经过上一篇<<树莓派-安装摄像头模块>>之后 raspistill 是树莓派基于摄像头拍照命令 比如我要截取一张宽1024px,高768px,旋转180度 ...
- jquery学习之$(document).ready()
参考资料: 1.W3School在线教程:http://www.w3school.com.cn/jquery/event_ready.asp 2.某人博客园:http://www.cnblogs.co ...
- checked、disabled在原生、jquery、vue下不同写法
以下是原生和jquery <!DOCTYPE html> <html> <head> <meta http-equiv="Content ...
- vue.js $set的使用 数组
[javascript] view plain copy <!DOCTYPE html> <html lang="en"> <head> < ...
- backface-visibility当元素不面向屏幕时是否可见
html代码 <h1>div1可见</h1> <div class="div1">div---1</div> <h1>d ...
- set statistics profile on实例
set statistics profile on实例 1.SQL语句实例 SQL 代码 复制 SET STATISTICS PROFILE ON GO SELECT COUNT(b.[Sal ...
- Python 之 %s字符串、%d整型、%f浮点型
%s string="hello" #%s打印时结果是hello print "string=%s" % string # output: string=hel ...