sgu291:Evolution(暴力)

暴力题就自己看题意吧,都不想打了  TAT 
AC code:

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define x first
#define y second
#define clr(a, b) memset(a, b, sizeof a)
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, a, b) for(int i = (a); i >= (b); --i)
typedef long long LL;
typedef double DB;
typedef long double LD;
using namespace std;

void open_init()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
}

void close_file()
{
    #ifndef ONLINE_JUDGE
    fclose(stdin);
    fclose(stdout);
    #endif
}

const int MAXQ = 1009;
const int MAXN = 22209;

int q, c, n, t;
int g[MAXQ][MAXQ];
queue< pii > act[MAXN];
int ans[MAXN], sum;
pii d[4];

inline void extend(int i)
{
    queue< pii > tmp;
    while(!act[i].empty())
    {
        int xi = act[i].front().x, yi = act[i].front().y;act[i].pop();
        rep(j, 0, 3)
            if(xi+d[j].x >= 1 && xi+d[j].x <= q && yi+d[j].y >= 1 && yi+d[j].y <= c)
                if(!g[xi+d[j].x][yi+d[j].y])
                {
                    g[xi+d[j].x][yi+d[j].y] = i;
                    tmp.push(mp(xi+d[j].x, yi+d[j].y));
                }
    }
    act[i] = tmp;
}

int main()
{
    open_init();

    d[0] = mp(0, 1), d[1] = mp(1, 0);
    d[2] = mp(-1, 0), d[3] = mp(0, -1);
    scanf("%d%d%d%d", &q, &c, &n, &t);
    rep(i, 1, n) 
    {
        int xi, yi;
        scanf("%d%d", &xi, &yi);
        act[i].push(mp(xi, yi));
        ans[i] = 1;sum++;g[xi][yi] = i;
    }
    while(t-- && sum < q*c)
    {
        rep(i, 1, n)
            if(act[i].size())
                extend(i);
        rep(i, 1, n)
            ans[i] += act[i].size();
        sum = 0;
        rep(i, 1, n)
            sum += ans[i];  
    }
    rep(i, 1, n)
        printf("%d\n", ans[i]);

    close_file();
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值