#pragma comment(linker, "/STACK:64000000")
#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <string>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
using namespace std;
#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define for1(i, n) for(int i = 1; i <= int(n); i++)
#define forv(i, v) forn(i, v.size())
#define VI vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define all(v) v.begin(), v.end()
#define NMAX 205
#define ZMAX 52
const int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1
};
const int dy[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int Delta[5] = {28, 27, 26, 20, 18};
int delta = 26;
const int magic = 7;
const int minSize = 10;
struct Point
{
int x, y;
};
char s[5];
int a[NMAX][NMAX], b[NMAX][NMAX];
int col[NMAX][NMAX];
vector<Point> comp[NMAX * NMAX];
int size[NMAX * NMAX];
int sum[NMAX * NMAX];
int cZone[ZMAX];
int t, q, w, h, cntC;
inline bool valid(int x, int y)
{
return (x >= 0 && y >= 0 && x < h && y < w);
}
void dfs(int x, int y, int c)
{
if(col[x][y] != - 1) return;
Point p = {x, y};
comp[c].push_back(p);
col[x][y] = c;
size[c]++;
sum[c]+= a[x][y];
forn(i, 8)
{
int xx = x + dx[i];
int yy = y + dy[i];
if(!valid(xx, yy)) continue;
if(abs(sum
[c
] / size
[c
] - a
[xx
][yy
]) > magic
) continue;
dfs(xx, yy, c);
}
}
int main()
{
forn(it, t)
{
scanf("%d %d %d", &q, &h, &w
);
forn(i, h)
{
forn(j, w)
{
}
}
-
forn(iter, 3)
{
cntC = 0;
forn(i, h)
{
forn(j, w)
{
if(col[i][j] != - 1) continue;
comp[cntC].clear();
dfs(i, j, cntC);
++cntC;
}
}
-
delta = Delta[iter];
forn(i, h)
{
forn(j, w)
{
if(size[col[i][j]]
>= minSize)
{
b[i][j] = a[i][j];
continue;
}
int cnt = 0;
double S = 0;
forn(l, 4)
{
int ii = i + dx[l];
int jj = j + dy[l];
if(!valid(ii, jj)) continue;
S+= a[
ii][jj];
++cnt;
}
double mid = S / cnt;
double midDif = 0;
forn(l, 4)
{
int ii = i + dx[l];
int jj = j + dy[l];
if(!valid(ii, jj)) continue;
midDif+=
abs(a
[ii
][jj
] - mid
);
}
midDif/= cnt;
if(abs(a
[i
][j
] - mid
) > midDif + delta
) {
b[i][j] = int(mid);
}
else
{
b[i][j] = a[i][j];
}
}
}
}
forn(i, h)
{
forn(j, w)
{
if(b
[i
][j
] <
100) printf("0");
}
}
}
return 0;
}
-
-