暴力题就自己看题意吧,都不想打了
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;
}