hdu5336 十滴水游戏的模拟

该博客介绍了如何使用C++编程实现十滴水游戏的模拟。通过初始化矩阵、处理滴水路径及更新矩阵,解决游戏过程中水滴碰撞和扩散的问题。在main函数中,读取游戏参数并进行模拟计算,输出每滴水在游戏结束时的状态。
摘要由CSDN通过智能技术生成
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
const int N=105;
int n,m,r,c;
int T;
int time;
int tot[2];
int sx,sy;
int dirx[]={0,0,1,-1};
int diry[]={1,-1,0,0};
int now;
int a[N][N];
int xx[N*N],yy[N*N];
int res[N][N];
int ans[N*N];
struct drop{
    int x,y;
    int dx,dy;
}d[2][N*N];
void init(){
    memset(a,0,sizeof a);
    memset(ans,0,sizeof ans);
    tot[0]=4;
    now=0;
}
void solve(int time){
    tot[now^1]=0;
    for(int i=0;i<tot[now];i++){
        drop t=d[now][i];
        t.x+=t.dx;
        t.y+=t.dy;
        if(t.x<1 || t.x>r || t.y<1 || t.y>c) continue;
        if(a[t.x][t.y]) {
            a[t.x][t.y]++;

        }else{
            d[now^1][tot[now^1]++]=drop{t.x,t.y,t.dx,t.dy};
        }

    }
    for(int i=0;i<n;i++){
        int x=xx[i],y=yy[i];
      
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值