# Untitled

unknown
plain_text
19 days ago
1.4 kB
0
Indexable
Never
```#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n"

const double PI = 3.14159265358979;
const ll INF =  1e9 + 7;
const ll MOD = 1e9 + 7;
const ll nax = 100005;
const int LOG = 25;

class Solver {

int n, m;
vector<vector<int> > a, dp;

public:
void solve() {
cin >> n >> m;
a.assign(n + 1, vector<int> (m + 1));
dp.assign(n + 1, vector<int> (m + 1, -1));

for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> a[i][j];

dp[i][j] = a[i][j];
if (i > 0) {
dp[i][j] = max(dp[i][j], dp[i - 1][j]);
if (j > 0) {
dp[i][j] = max(dp[i][j], dp[i - 1][j - 1]);
}
if (j < m) {
dp[i][j] = max(dp[i][j], dp[i - 1][j + 1]);
}
}
}
}

for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << (a[i][j] >= dp[i][j]);
}
cout << endl;
}
}
};

signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);

int t = 1;
cin >> t;
while(t--) {
Solver solver;
solver.solve();
}

return 0;
}```