output stringlengths 52 181k | instruction stringlengths 296 182k |
|---|---|
#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 28;
const double INF = 1e12, EPS = 1e-9;
int mx, my, MX, MY, mk, MK, ml, ML, cnt;
int n, h, w;
string in[250];
void rec(int y, int x) {
in[y][x] = '2';
cnt++;
mx = min(mx, x);
MX = max(MX, x);
my = min(my, y);
MY = max(MY, y);
mk = min(mk,... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
using namespace std;
char a[(1 << 8)][(1 << 8)];
int TESTCASE;
int n, m;
int DFS;
int Ans;
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
void dfs(int x, int y) {
if (x < 0 || x >= n || y < 0 || y >= m || a[x][y] != '1') {
return;
}
a[x][y]... | ### Prompt
Create a solution in cpp for the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each s... |
#include <bits/stdc++.h>
const int maxn = 260;
const int d[][2] = {{-1, -1}, {-1, 0}, {-1, 1}, {0, 1},
{1, 1}, {1, 0}, {1, -1}, {0, -1}};
int t, n, m, cnt;
char g[maxn][maxn];
bool v[maxn][maxn];
int calc1(int x, int y) {
int row = 1, col = 1;
for (int i = x + 1; i < n && g[i][y] == '1'; i++)... | ### Prompt
Please formulate a cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
int n, m;
string c[250];
bool was[250][250];
int cnt;
vector<pair<int, int> > q;
void analyze() {
int mix = 5000, maX = -5000;
int miy = 5000, may = -5000;
for (int i = 0; i < (int)(((int)((q).size()))); ++i) {
pair<int,... | ### Prompt
Create a solution in cpp for the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each s... |
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
void __never(int a) { printf("\nOPS %d", a); }
bool M[256][256];
int n, m;
char ch[500];
inline bool it_is(int x, int y, string str) {
if (x < 1 || y < 1 || x > n || y > m) return false;
int i = 0;
for (int a = (x - 1); a <= ... | ### Prompt
Generate a cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each sid... |
#include <bits/stdc++.h>
using namespace std;
int test;
int n, m;
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
char a[300][300];
int used[300][300];
bool val(int x, int y) { return (0 <= x && x < n && 0 <= y && y < m); }
bool check(int x, int y) {
for (int i = 0; i < 8; i++)
if ... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
using namespace std;
namespace QoE_Library {
namespace QL_Bare_Minimum {
const double PI = 3.141592653589793238460;
const long double pi = 10000 * acos(-1.0L);
const long double E = 2.7182818284590452353;
const long double eps = 1e-10;
const int DX4[] = {0, 1, 0, -1};
const int DY4[] = {1, 0, -... | ### Prompt
Please create a solution in cpp to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
void pv(T a, T b) {
for (T i = a; i != b; ++i) cout << *i << " ";
cout << endl;
}
int in_c() {
int c;
for (; (c = getchar()) <= ' ';) {
if (!~c) throw ~0;
}
return c;
}
int in() {
int x = 0, c;
for (; (unsigned)((c = getchar()) - '0') ... | ### Prompt
Please formulate a Cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
int n, m, dx[] = {-1, -1, 0, 1, 1, 1, 0, -1},
dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
char g[255][255];
void dfs(int x, int y, vector<pair<int, int>> &v) {
v.emplace_back(x, y);
g[x][y] = '0';
for (int d = 0; d < 8; d++) {
int nx = x + dx[d], ny = y + dy[d];... | ### Prompt
Your task is to create a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares... |
#include <bits/stdc++.h>
using namespace std;
char d[257][257] = {};
bool check1(int x, int y, int sz, char val) {
for (int i = 0; i <= sz; i++)
if (d[x + i][y] != val || d[x + i][y + sz] != val ||
d[x + sz][y + i] != val || d[x][y + i] != val)
return false;
return true;
}
void fill1(int x, int y,... | ### Prompt
Develop a solution in Cpp to the problem described below:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
char a[280][280];
int n, m, t, z, s, X[8] = {0, 1, 0, -1, 1, 1, -1, -1},
Y[8] = {1, 0, -1, 0, 1, -1, 1, -1};
int check(int d, int x, int y, int l, int r) {
for (int i = 0; i <= d; i++)
for (int j = l; j < r; j++)
if (x + X[j] * i < 0 || x + X[... | ### Prompt
Construct a CPP code solution to the problem outlined:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with eac... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300;
const int MAXM = 250;
const int dr[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dc[8] = {1, 0, -1, 0, 1, -1, 1, -1};
char a[MAXN][MAXN];
int n, m;
void Find_Square(int r, int c, int &cnt) {
if (r < 0 || r >= m || c < 0 || c >= n || a[r][c] != '1') ret... | ### Prompt
Construct a Cpp code solution to the problem outlined:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with eac... |
#include <bits/stdc++.h>
using namespace std;
char a[254][254];
int floodC;
void flood(int x, int y) {
if (a[x][y] != '1') return;
++floodC;
a[x][y] = '2';
flood(x - 1, y);
flood(x + 1, y);
flood(x - 1, y - 1);
flood(x + 1, y + 1);
flood(x - 1, y + 1);
flood(x + 1, y - 1);
flood(x, y - 1);
flood(x... | ### Prompt
Please provide a cpp coded solution to the problem described below:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
using namespace std;
int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int m, n;
char a[255][255];
pair<int, int> ds[5000];
int nd;
bool check(int i, int j, int bit) {
for (int h = 0; h < 8; ++h)
if ((bit & (1 << h)) == 0) {
int x = i + dx[h];
i... | ### Prompt
Construct a cpp code solution to the problem outlined:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with eac... |
#include <bits/stdc++.h>
using namespace std;
int t, n, m, cnt, xmin, xmax, ymin, ymax, head, tail, g[250 + 2][250 + 2],
f[250 + 2][250 + 2], qx[250 * 250], qy[250 * 250];
bool checkType1() {
if (tail != 4 * (xmax - xmin)) return false;
for (int i = xmin; i <= xmax; ++i) {
if (f[i][ymin] != cnt) return fals... | ### Prompt
Please create a solution in cpp to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') f = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + ch - 48;
ch = getchar();
}
return x * f;
}
const int dx[9] = {0, 1, 1, 1, 0, 0, -1, -1... | ### Prompt
Generate a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each sid... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 250 + 10;
char A[MAXN][MAXN];
const int Dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int Dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
vector<pair<int, int> > res;
int R, C;
bool ok(int x, int y) { return x >= 0 && x < R && y >= 0 && y < C; }
int mk[MAXN][MAXN];
void fl... | ### Prompt
Construct a Cpp code solution to the problem outlined:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with eac... |
#include <bits/stdc++.h>
using namespace std;
const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int t, ans, n, m;
int a[256][256], u[256][256];
char c;
void work(int x, int y) {
int tx, ty;
u[x][y] = 1;
for (int i = 0; i <= 7; i++) {
tx = x + dx[i];
ty = y + dy[... | ### Prompt
Please formulate a cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = acos(-1.0);
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int N, M;
char v[260][260];
bool visited[260][260];
bool con[260][260], cont[260][260];
void dfs(int j, int k) {
visited[j][k] = true;
... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:36777216")
using namespace std;
char s[255][255];
int u[255][255];
int now;
int n, m, cc;
void dfs(int x, int y) {
if (u[x][y] == now) return;
u[x][y] = now;
cc++;
for (int dx(-1); dx < (2); dx++)
for (int dy(-1); dy < (2); dy++) {
int nx = x + ... | ### Prompt
Create a solution in Cpp for the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each s... |
#include <bits/stdc++.h>
using namespace std;
char tab[260][260];
int ext[2][260][260][2];
int extd[2][260][260][2];
bool checksq(int i, int j, int sz, int num) {
if (sz == 0) return true;
assert(i + sz - 1 <= 253 && j + sz - 1 <= 253);
return ext[num][i][j][0] >= sz && ext[num][i][j][1] >= sz &&
ext[num... | ### Prompt
Please create a solution in Cpp to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 250;
const int INF = (int)1e9;
const int MOVE[8][2] = {{0, -1}, {0, 1}, {-1, 0}, {1, 0},
{-1, 1}, {-1, -1}, {1, -1}, {1, 1}};
int n, m;
int mat[N][N];
bool visited[N][N];
vector<pair<int, int> > v;
void dfs(int x, int y) {
visited[x... | ### Prompt
Please formulate a Cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
char buf[1000];
int n, m;
bool ok(int a, int b) { return (a < n && b < m && a > -1 && b > -1); }
int dx[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
vector<string> s;
bool Type2(int x, int y) {
int xx = x, yy = y;
int l = 0;
while (ok(x, ... | ### Prompt
Please formulate a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
const int X[8] = {0, 1, 0, -1, 1, 1, -1, -1},
Y[8] = {1, 0, -1, 0, 1, -1, 1, -1};
int n, m, s;
char a[300][300];
void judge(int x, int y, int &s) {
if (x < 0 || x >= n || y < 0 || y >= m || a[x][y] != '1') return;
a[x][y] = '2', s++;
for (int i = 0; i <= 7; i++) judge(x + X[i], ... | ### Prompt
Construct a CPP code solution to the problem outlined:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with eac... |
#include <bits/stdc++.h>
using namespace std;
int a[260][260], T, TT, m, n, ttp;
bool ttp2;
string x;
bool ss(int u, int v) {
int i, j, an = 0, an2 = 0;
an = a[u][v + 1] + a[u][v - 1] + a[u + 1][v] + a[u - 1][v];
an2 = a[u + 1][v + 1] + a[u + 1][v - 1] + a[u - 1][v + 1] + a[u - 1][v - 1];
if (an == 2 && an2 <= ... | ### Prompt
Your task is to create a Cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 255;
const int d[8][2] = {{1, 1}, {1, -1}, {-1, -1}, {-1, 1},
{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
char s[MAXN][MAXN];
int res, tot, vis[MAXN][MAXN];
queue<int> qx, qy, sx, sy;
int bfs(int x, int y, int n, int m) {
vis[x][y] = ++tot;
... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
using namespace std;
int n, m, cnt, cou;
char board[300][300];
void search(int i, int j) {
for (int p = -1; p < 2; p++)
for (int q = -1; q < 2; q++) {
if (p == 0 && q == 0) continue;
int y = i + p, x = j + q;
if (y < 0 || y >= n || x < 0 || x >= m) continue;
if (bo... | ### Prompt
Develop a solution in CPP to the problem described below:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
char inp[260][260];
bool cov[260][260];
int mx, my, Mx, My;
vector<int> outai;
vector<int> outaj;
void dfs(int i, int j) {
cov[i][j] = true;
mx = min(mx, j);
my = min(i, my);
Mx = max(Mx, j);
My = max(My, i);
outai.push_back(i);
outaj.push_back(j);
... | ### Prompt
Create a solution in CPP for the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each s... |
#include <bits/stdc++.h>
enum vertex { N, S, W, E, NW, SW, NE, SE };
enum edge { E_W, S_N, SE_NW, SW_NE };
char a[250][250 + 1];
int dp0[250][250], dp1[250][250];
int n, m;
int one(int i, int j) {
return i >= 0 && i < n && j >= 0 && j < m && a[i][j] == '1';
}
int check4(int i, int j) {
return !one(i - 1, j) && !one... | ### Prompt
In cpp, your task is to solve the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each ... |
#include <bits/stdc++.h>
using namespace std;
int n, m, ans, flag, cnt, tot, rx, ry, edge;
char mp[305][305];
bool vis[305][305];
int dx[] = {-1, 1, 0, 0, -1, -1, 1, 1};
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
struct node {
int x, y;
} q[90005];
bool isok(int x, int y) {
if (x < 1 || x > n || y < 1 || y > m || mp[x... | ### Prompt
Create a solution in Cpp for the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each s... |
#include <bits/stdc++.h>
using namespace std;
bool matrix[300][300];
bool isfree(int i, int j, int x1, int y1, int x2, int y2, int x3 = 0,
int y3 = 0) {
int res = (int)matrix[i][j - 1] + (int)matrix[i - 1][j - 1] +
(int)matrix[i - 1][j] + (int)matrix[i - 1][j + 1] +
(int)matrix[i][... | ### Prompt
Construct a cpp code solution to the problem outlined:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with eac... |
#include <bits/stdc++.h>
using namespace std;
void die(string S) {
puts(S.c_str());
exit(0);
}
const int dx[] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy[] = {-1, 0, 1, 1, 1, 0, -1, -1};
vector<int> seq;
char G[255][255];
bool vis[255][255];
int type[255][255];
void dfs(int x, int y) {
vis[x][y] = true;
seq.pus... | ### Prompt
Create a solution in cpp for the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each s... |
#include <bits/stdc++.h>
using namespace std;
int t, n, m;
char c[257][257];
bool vis[257][257];
int ile[257][257];
int main() {
scanf("%d", &t);
while (t--) {
scanf("%d%d", &n, &m);
memset((c), 0, sizeof(c));
for (int i = 0; i < (n); i++) scanf("%s", c[i + 1] + 1);
int res = 0;
memset((vis), 0,... | ### Prompt
Generate a Cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each sid... |
#include <bits/stdc++.h>
using namespace std;
inline void read(register int *n) {
register char c;
*n = 0;
do {
c = getchar();
} while (c < '0' || c > '9');
do {
*n = c - '0' + *n * 10;
c = getchar();
} while (c >= '0' && c <= '9');
}
char b[300][300];
int r, c;
vector<pair<int, int> > V;
void f... | ### Prompt
Generate a cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each sid... |
#include <bits/stdc++.h>
using namespace std;
char in[255][255];
int X, Y;
int try1(int y, int x) {
int length = 0;
for (length = 1;; length++) {
if (y + length - 1 >= Y || x + length - 1 >= X ||
in[y + length - 1][x] != '1')
break;
}
length--;
bool OK = 1;
for (int yy = y; yy <= y + lengt... | ### Prompt
Please provide a CPP coded solution to the problem described below:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
using namespace std;
int t, R, C;
char b[300][300];
int l[300][300], d[300][300], rd[300][300], ld[300][300];
bool mark[300][300];
int dir[8][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0},
{1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
void L(int x, int y, int L, set<pair<int, int> >& s) {
f... | ### Prompt
Develop a solution in CPP to the problem described below:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
int t, n, m, u[255][255], ans, t1, t2;
char ch, map[255][255];
bool flag;
int main() {
scanf("%d", &t);
for (; t; t--) {
scanf("%d %d", &n, &m);
ch = getchar();
memset(u, 0, sizeof(u));
for (int i = 0; i < n; i++) {
gets(map[i]);
}
for (int i = 0; i < n; i++) {... | ### Prompt
Create a solution in CPP for the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each s... |
#include <bits/stdc++.h>
using namespace std;
char s[300][300];
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, -1, 1, -1, 1};
int n, m;
void dfs(int x, int y, int &t) {
if (x < 0 || x >= n || y < 0 || y >= m || s[x][y] != '1') return;
s[x][y] = '2';
t++;
for (int i = 0; i < 8; i++) {
dfs... | ### Prompt
Please provide a CPP coded solution to the problem described below:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
char str[260][260];
int a[10010];
int main(void) {
int t, n, m;
scanf("%d", &t);
for (int mm = 1; mm <= t; mm++) {
int ans = 0;
scanf("%d%d", &n, &m);
getchar();
for (int i = 0; i < n; i++) {
gets(str[i]);
}
for (int i = 0; i < n; i++) {
for (int j = 0;... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
const int MAXN = 250 + 5;
int a[MAXN][MAXN], n, m;
char s[MAXN];
bool vis[MAXN][MAXN];
int bel[MAXN][MAXN];
int cnt, ts;
int mnx, mny, mxx, mxy;
inline void dfs(int x, int y) {
vis[x][y] = 1;
++cnt;
bel[x][y] = ts;
mnx = std::min(mnx, x);
mxx = std::max(mxx, x);
mny = std::min(mny, ... | ### Prompt
Your task is to create a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
char a[260][260];
int cnt, col, ans;
int ex, ey;
int vis[260][260];
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
bool bdj(int i, int j) {
if (i >= 1 && i <= n && j >= 1 && j <= m) return true;
return false;
}
void dfs(int i, int ... | ### Prompt
In CPP, your task is to solve the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 250 + 11;
const long long MOD = 1e9 + 7;
int fdown[N][N], fright[N][N], a[N][N], f1[N][N], f2[N][N], sdown[N][N],
sright[N][N], s1[N][N], s2[N][N];
inline void gets() {
int n = 5, m = 5;
cin >> n >> m;
for (int i = 0; i <= n + 1; i++)
for (int j ... | ### Prompt
Please formulate a Cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, -1, -1, 0, 1, 1, 1, 0},
dy[] = {-1, 0, 1, 1, 1, 0, -1, -1};
int used[300][300], board[300][300];
int T, n, m, cnt, xmax, xmin, ans;
void dfs(int x, int y) {
if (used[x][y] || !board[x][y]) return;
used[x][y] = 1;
cnt++;
xmax = max(xma... | ### Prompt
Create a solution in cpp for the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each s... |
#include <bits/stdc++.h>
const long long INF32 = 1e9;
const long long INF64 = 1e17;
const int RANGE = 1e6 + 5;
using namespace std;
template <class T>
void read(T &Val) {
T tmp = 0;
char ch = getchar();
int flag = 1;
while (!(ch >= '0' && ch <= '9')) {
if (ch == '-') flag = -1;
ch = getchar();
}
whi... | ### Prompt
Generate a Cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each sid... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
char field[300][300];
int check_p(int si, int sj, int d) {
for (int k = 0; k < d + 1; k++)
if (field[si][sj + k] == '0') return false;
for (int k = 0; k < d + 1; k++)
if (field[si + k][sj] == '0') return false;
for (int k = 0; k < d + 1; k++)
if ... | ### Prompt
Develop a solution in Cpp to the problem described below:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
long long a[100010], b[101010] = {0};
char s[520][520] = {0};
int t, n, m, X[9] = {0, 1, 1, 1, 0, 0, -1, -1, -1},
Y[9] = {0, 1, 0, -1, 1, -1, 1, 0, -1};
int dfs(int x, int y, int &t) {
int i;
if (s[x][y] != '1') return 0;
s[x][y] = '2';
t++;
for (i = ... | ### Prompt
Develop a solution in Cpp to the problem described below:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
using namespace std;
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
char a[300][300];
i... | ### Prompt
Please formulate a cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
int n, m, Bcnt;
char st[510][510];
int dx[8] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};
int g[510][510];
int hashp[110000];
bool check(int x, int y) {
if (x <= 0 || x > n) return false;
if (y <= 0 || y > m) return false;
if (st[x][y] == '0... | ### Prompt
Please formulate a cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
int grid[250][250];
int deltax[] = {0, 1, 1, 1, 0, -1, -1, -1};
int deltay[] = {1, 1, 0, -1, -1, -1, 0, 1};
bool valid(int x, int y) {
if (x >= n || y >= m || x < 0 || y < 0) return false;
return true;
}
int consider[][8] = {{0, 1, 0, 1, 1, 1, 1, 0},
... | ### Prompt
Please formulate a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
char M[500][500];
int sx, sy;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
int main() {
int t;
scanf("%d", &t);
for (int I = 0; I < t; I++) {
int ret = 0;
memset(M, 0, sizeof M);
scanf("%d%d", &sy, &sx);
for (int i = ... | ### Prompt
Your task is to create a Cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares... |
#include <bits/stdc++.h>
using namespace std;
const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int t, ans, n, m;
int a[256][256], u[256][256];
char c;
void work(int x, int y) {
int tx, ty;
u[x][y] = 1;
for (int i = 0; i <= 7; i++) {
tx = x + dx[i];
ty = y + dy[... | ### Prompt
In Cpp, your task is to solve the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each ... |
#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, k, t;
int main() {
scanf("%d", &t);
for (k = 0; k < t; k++) {
scanf("%d %d", &n, &m);
int res = 0;
char a[252][252];
bool b[252][252];
short sum_row[252][252];
short sum_col[252][252];
short sum_d1[252][252];
short sum_d2[... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
using namespace std;
int dd[3] = {-1, 0, 1};
void extract(vector<string> &board, int i, int j,
set<pair<int, int> > &coords) {
if (board[i][j] != '1') return;
board[i][j] = '0';
coords.insert(pair<int, int>(i, j));
for (int k = 0; k < 3; k++) {
for (int l = 0; l < 3; l+... | ### Prompt
Generate a cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each sid... |
#include <bits/stdc++.h>
using namespace std;
int d[8][2] = {{0, 1}, {-1, 0}, {1, 0}, {0, -1},
{1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
int T;
int n, m, tot;
char c[253][253];
int check1(int sx, int sy) {
int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0;
while (sx < n && c[sx + 1][sy]) sx++, cnt1++;
while (... | ### Prompt
In Cpp, your task is to solve the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each ... |
#include <bits/stdc++.h>
inline int cmp(double x, double y = 0, double tol = 1e-9) {
return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
int n, m;
int map[300][300];
int main() {
int t;
char c;
std::cin >> t;
while (t--) {
memset(map, 0, sizeof(map));
int answer = 0;
std::cin >> n >> m;
for ... | ### Prompt
Construct a Cpp code solution to the problem outlined:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with eac... |
#include <bits/stdc++.h>
using namespace std;
struct cell {
int r, d, m, nm;
};
cell b[300][300], c[300][300];
char a[300][300];
int main(void) {
int t, ans, n, m;
scanf("%d", &t);
char ch;
while (t--) {
ans = 0;
memset(b, 0, sizeof(b));
memset(c, 0, sizeof(c));
for (int i = 0; i < 300; i++)
... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 250 + 10;
const int MAXM = 250 + 10;
inline void clear(int a[], int n) { memset(a, 0, (n + 1) << 2); }
char s[MAXN][MAXM];
int r[2][MAXN][MAXM], d[2][MAXN][MAXM], rd[2][MAXN][MAXM], ld[2][MAXN][MAXM];
void solve(void) {
int n, m;
scanf("%d%d", &n, &m);
... | ### Prompt
Please provide a cpp coded solution to the problem described below:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
using namespace std;
const int maxN = 300;
bool matrix[maxN][maxN];
int nRows, nColumns;
int leftStreak[maxN][maxN], downStreak[maxN][maxN];
int findRight() {
for (int y = 0; y < nRows; y++)
for (int x = nColumns - 1; x >= 0; x--)
leftStreak[x][y] = (x != nColumns - 1) ? (matrix[x][... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
using namespace std;
char mat[250 + 2][250 + 2];
int get_state(int x, int y) {
int state = 0;
for (int i = x - 1; i <= x + 1; ++i) {
for (int j = y - 1; j <= y + 1; ++j) {
if (mat[i][j] >= '1') {
state |= 1 << ((i - x + 1) * 3 + (j - y + 1));
}
}
}
return sta... | ### Prompt
Create a solution in cpp for the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each s... |
#include <bits/stdc++.h>
using namespace std;
char s[300][300];
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, -1, 1, -1, 1};
int n, m;
void dfs(int x, int y, int& t) {
if ((x < 0) || (x >= n) || (y < 0) || (y >= m) || (s[x][y] != '1')) return;
s[x][y] = '2';
t++;
for (int i = 0; i < 8; i++)... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void checkmin(T &a, const T &b) {
if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, const T &b) {
if (b > a) a = b;
}
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int maxn = 3... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
using namespace std;
char mm[256][256];
vector<pair<int, int> > pts;
int n, m;
int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
void dfs(int x, int y) {
pts.push_back(make_pair(x, y));
mm[x][y] = '0';
for (int i = 0; i < 8; ++i) {
int newx = x + dx[i];... | ### Prompt
Construct a Cpp code solution to the problem outlined:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with eac... |
#include <bits/stdc++.h>
constexpr int MAXN = 255;
using namespace std;
int testCase, n, m, cnt, tot;
int Cnt1, Cnt2, Cnt3, Cnt4;
int mp[MAXN][MAXN], vis[MAXN][MAXN], cpy[MAXN][MAXN];
int dr[8] = {1, 1, 1, 0, 0, -1, -1, -1};
int dc[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
inline void clear(int r, int c) {
mp[r][c] = 0, tot+... | ### Prompt
Generate a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each sid... |
#include <bits/stdc++.h>
using namespace std;
const int mr[] = {0, 1, 0, -1, -1, -1, 1, 1};
const int mc[] = {1, 0, -1, 0, -1, 1, -1, 1};
int a[256][256];
int b[256][256];
vector<pair<int, int>> u;
void scan(int sr, int sc) {
a[sr][sc] = 0;
u.push_back({sr, sc});
for (int o = 0; o < 8; o++) {
int tr = sr + mr... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
constexpr int MAXN = 255;
using namespace std;
int testCase, n, m, cnt, tot, Cnt1, Cnt2, Cnt3, Cnt4;
int mp[MAXN][MAXN];
int dr[8] = {1, 1, 1, 0, 0, -1, -1, -1};
int dc[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
inline void clear(int r, int c) {
mp[r][c] = 0, tot++;
for (int i = 0; i < 8; i++) {
... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 300, dr[8] = {0, +1, +1, +1, 0, -1, -1, -1},
dc[8] = {+1, +1, 0, -1, -1, -1, 0, +1};
int a[N][N], num[N][N], low[N][N], cnt, tc, n, m;
bool inside(int r, int c) { return (r >= 1 && r <= n && c >= 1 && c <= m); }
pair<int, int> visit(int r, int c, que... | ### Prompt
Develop a solution in cpp to the problem described below:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
int size(const T& c) {
return (int)c.size();
}
template <typename T>
void remin(T& a, const T& b) {
if (b < a) a = b;
}
template <typename T>
void remax(T& a, const T& b) {
if (b > a) a = b;
}
template <typename T>
T abs(T x) {
return x < 0 ? -... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
using namespace std;
char s[300][300];
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, -1, 1, -1, 1};
int n, m, d, ans;
void dfs(int x, int y) {
if (x < 0 || x >= n || y < 0 || y >= m || s[x][y] != '1') return;
s[x][y] = '2';
++d;
for (int i = 0; i < 8; ++i) dfs(x + d... | ### Prompt
Construct a CPP code solution to the problem outlined:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with eac... |
#include <bits/stdc++.h>
using namespace std;
struct pa {
int i, j;
};
vector<pa> v, v2;
char a[260][260];
bool b[260][260];
bool type1(vector<pa> &v) {
int maxl = 10000, maxr = -10000, maxu = 10000, maxd = -10000;
int S = v.size() / 4;
int l, r, u, d = l = r = u = 0;
for (int i = 0; i < v.size(); i++) {
... | ### Prompt
Please create a solution in CPP to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
int n, m, t;
char s[256];
int a[300][300], sh[300][330], sv[300][300], ss[300][300], sb[300][300];
bool fullh(int i1, int j1, int i2, int j2) {
return sh[i1][j2] - sh[i1][j1 - 1] == j2 - j1 + 1;
}
bool freeh(int i1, int j1, int i2, int j2) {
return sh[i1][j2] - sh[i1][j... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:32000000")
void initf() {}
using namespace std;
const int inf = (1 << 29);
char a[261][261];
int n, m;
int sum1[261][261];
int sum2[261][261];
int sum3[511][511];
int sum4[511][511];
inline int get1(int x, int y, int s) {
if (y == 0) return (sum1[x][y + s - 1])... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vvi = vector<vi>;
usin... | ### Prompt
Construct a cpp code solution to the problem outlined:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with eac... |
#include <bits/stdc++.h>
using namespace std;
void traverse(int n, int m, vector<string>& vec, vector<pair<int, int> >& res,
int i, int j, bool& ok) {
int dxx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dyy[] = {0, -1, 0, 1, 1, -1, -1, 1};
if (vec[i][j] == 'x') ok = false;
if (!ok) return;
if (vec[i][j] == '... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
using namespace std;
int board[300][300], n, m;
char s[300];
int work(int x, int y) {
board[x][y] = 2;
if (board[x - 1][y - 1] || board[x][y - 1] || board[x - 1][y] ||
board[x - 1][y + 1])
return 0;
if (board[x][y + 1] && board[x + 1][y]) {
int step = 1, cnt = 0;
while (... | ### Prompt
Your task is to create a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares... |
#include <bits/stdc++.h>
using namespace std;
int mx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int my[] = {1, -1, 0, 0, 1, -1, 1, -1};
int n, m;
string a[500];
int used[500][500];
int qi[1000000];
int qj[1000000];
int qs, qe;
int bfs(int i, int j) {
qs = 0;
qe = 1;
int ret = 0;
qi[0] = i;
qj[0] = j;
used[i][j] = 1;
... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
void __never(int a) { printf("\nOPS %d", a); }
int dx[] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int INF = 1000000;
int T;
int n, m;
char s[256][256];
bool flag[256][256];
pair<int, int> ord[256 ... | ### Prompt
Generate a Cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each sid... |
#include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
using namespace std;
const int N = 255;
int t, n, m, k;
char s[N][N];
int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
void dfs(int x, int y) {
s[x][y] = '!';
k++;
for (int i = 0; i <= 7; i++) {
int xx = x + dx[i];
int y... | ### Prompt
Develop a solution in Cpp to the problem described below:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(const T &a) {
return a * a;
}
const int turn4[2][4][2] = {{{0, 1}, {0, -1}, {1, 0}, {-1, 0}},
{{1, 1}, {-1, 1}, {1, -1}, {-1, -1}}};
const int turn8[8][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0},
{... | ### Prompt
Please formulate a cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 505;
int t, n, m, ans, d;
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, -1, 1, -1, 1};
char s[N][N];
void DFS(int x, int y) {
if (x < 0 || x >= n || y < 0 || y >= m || s[x][y] != '1') return;
s[x][y] = '2', d++;
for (int i = 0; i < 8... | ### Prompt
Generate a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each sid... |
#include <bits/stdc++.h>
int x, y;
char in[300][300];
int cnt;
void nul(int a, int b, char from, char to) {
int i, j;
if (a < 0 || b < 0 || a >= x || b >= y || in[a][b] != from) return;
cnt++;
in[a][b] = to;
for (i = -1; i < 2; i++)
for (j = -1; j < 2; j++) nul(a + i, b + j, from, to);
}
int is_ok(int i, ... | ### Prompt
Please formulate a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
int bitct(long long r) { return r == 0 ? 0 : (bitct(r >> 1) + (r & 1)); }
long long gcd(long long x, long long y) { return x ? gcd(y % x, x) : y; }
template <typename T>
ostream &operator<<(ostream &o, vector<T> v) {
o << "{";
int i = 0, s = v.size();
for (; i + 1 < s... | ### Prompt
Create a solution in cpp for the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each s... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
bool ok;
vector<string> A;
vector<int> st;
const int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};
void dfs(int x, int y) {
A[x][y] = '2';
int sons = 0;
for (int dir = 0; dir < 8; ++dir) {
int newx = x + dx[dir];
... | ### Prompt
Please create a solution in cpp to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
void paint(vector<string> &bd, int i, int j, set<pair<int, int> > &ss) {
int h = bd.size();
int w = bd[0].length();
if (!(i >= 0 && j >= 0 && i < h && j < w)) return;
if (bd[i][j] == '0') return;
ss.insert(make_pair(i, j));
bd[i][j] = '0';
paint(bd, i + 0, j +... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') f = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + ch - 48;
ch = getchar();
}
return x * f;
}
const int dx[9] = {0, 1, 1, 1, 0, 0, -1, -1... | ### Prompt
Create a solution in Cpp for the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each s... |
#include <bits/stdc++.h>
using namespace std;
int N, M, T;
string line[1000];
int minx, maxx, miny, maxy;
int cnt;
void fill(int x, int y) {
minx = min(minx, x);
maxx = max(maxx, x);
miny = min(miny, y);
maxy = max(maxy, y);
cnt++;
line[x][y] = '2';
for (int nx = x - 1; nx <= x + 1; ++nx)
for (int ny ... | ### Prompt
Please create a solution in Cpp to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
char mapp[255][255];
int vis[255][255];
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
queue<pair<int, int> > Q;
int testn, n, m, e1, e2, e3, e4, dir, ans, nowx, nowy, pathsize;
int newx, newy, cnt;
int bfs(int x, int y) {
pathsize = 0;
... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
using namespace std;
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int MAXN = 300 + 10;
char a[MAXN][MAXN];
int n, m;
void dfs(int x, int y, int& s) {
if (x < 0 || x >= n || y < 0 || y >= m || a[x][y] != '1') return;
a[x][y] = '2';
++s;
... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
using namespace std;
char s[300][300];
int n, m;
const int dr[] = {+0, +1, +0, -1, +1, +1, -1, -1};
const int dc[] = {+1, +0, -1, +0, -1, +1, -1, +1};
int tot;
void dfs(int r, int c) {
s[r][c] = '2', tot++;
for (int i = 0; i < 8; i++) {
int p = r + dr[i];
int q = c + dc[i];
if (... | ### Prompt
Please create a solution in CPP to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline _T sqr(const _T &x) {
return x * x;
}
template <class _T>
inline string tostr(const _T &a) {
ostringstream os("");
os << a;
return os.str();
}
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-11;
const i... | ### Prompt
Please create a solution in CPP to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
int qx[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int qy[8] = {1, 1, 1, 0, -1, -1, -1, 0};
string a[253];
int n, m;
int que(int x, int y) {
int ans = 1;
queue<pair<int, int> > q;
pair<int, int> T;
T.first = x;
T.second = y;
a[x][y] = '0';
q.push(T);
while (!q.empty()... | ### Prompt
Please formulate a Cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
using namespace std;
void check(int A[][252], int i, int j, int &v, int n, int m);
bool type1(int A[][252], int i, int j, int k, int l);
bool type2(int A[][252], int i, int j, int k, int m);
int main() {
int n, m, i, j, v = 0, p, q;
char in[250][250];
int A[252][252] = {0};
cin >> q;
... | ### Prompt
Construct a CPP code solution to the problem outlined:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with eac... |
#include <bits/stdc++.h>
using namespace std;
int t, m, n;
int A[250][250];
int reg = 0;
bool used[250][250];
int di[8] = {0, -1, 0, 1, 1, 1, -1, -1};
int dj[8] = {-1, 0, 1, 0, 1, -1, -1, 1};
vector<int> dir;
bool isnt;
void dfs(int i, int j) {
A[i][j] = reg;
used[i][j] = 1;
bool begin = 1;
for (int k = 0; k < ... | ### Prompt
Create a solution in CPP for the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each s... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000;
const double EPS = 1e-9;
const int N = 300;
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
int n, m;
int a[N][N];
enum STATE { ZERO, L, R, T, B, LT, RT, LB, RB };
int z[N][N];
pair<int, int> d[... | ### Prompt
Please create a solution in Cpp to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
char str[260][260];
int main(void) {
int t, n, m;
scanf("%d", &t);
while (t--) {
int ans = 0;
scanf("%d%d", &n, &m);
getchar();
for (int i = 0; i < n; i++) gets(str[i]);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (str[i][j] == '1') {
... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squ... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
char inp[260][260];
bool cov[260][260];
int mx, my, Mx, My;
vector<int> outai;
vector<int> outaj;
void dfs(int i, int j) {
cov[i][j] = true;
mx = min(mx, j);
my = min(i, my);
Mx = max(Mx, j);
My = max(My, i);
outai.push_back(i);
outaj.push_back(j);
... | ### Prompt
Develop a solution in cpp to the problem described below:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with ... |
#include <bits/stdc++.h>
constexpr int MAXN = 255;
using namespace std;
int testCase, n, m, cnt, tot, Cnt1, Cnt2, Cnt3, Cnt4;
int mp[MAXN][MAXN];
int dr[8] = {1, 1, 1, 0, 0, -1, -1, -1};
int dc[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
inline void clear(int r, int c) {
mp[r][c] = 0, tot++;
for (int i = 0; i < 8; i++) {
... | ### Prompt
Generate a cpp solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each sid... |
#include <bits/stdc++.h>
#pragma GCC optimize("O500")
#pragma comment(linker, "/STACK:1677777216")
#pragma warning(default : 4)
using namespace std;
const double eps = 1e-12;
const int oo = 0x3F3F3F3F;
const long long ooLL = 0x3F3F3F3F3F3F3F3FLL;
const int MOD = 1000000007;
template <typename T>
T sqr(T x) {
return x... | ### Prompt
Create a solution in Cpp for the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each s... |
#include <bits/stdc++.h>
char str[260][260];
int main(void) {
int t, n, m;
scanf("%d", &t);
while (t--) {
int ans = 0;
scanf("%d%d", &n, &m);
getchar();
for (int i = 0; i < n; i++) gets(str[i]);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (str[i][j] == '1') {
... | ### Prompt
Construct a CPP code solution to the problem outlined:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with eac... |
#include <bits/stdc++.h>
using namespace std;
const int N = 505;
int t, n, m, ans, d;
int xx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int yy[8] = {1, 0, -1, 0, -1, 1, -1, 1};
char shu[N][N];
void dfs(int x, int y) {
if (x < 0 || x >= n || y < 0 || y >= m || shu[x][y] != '1') return;
shu[x][y] = '2', d++;
for (int i = 0;... | ### Prompt
Create a solution in cpp for the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each s... |
#include <bits/stdc++.h>
using namespace std;
char maps[255][255];
int n, m, T, ans, num, i, j;
int X[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int Y[8] = {1, 0, -1, 0, 1, -1, 1, -1};
int check(int x, int y, int l, int r) {
for (int i = 0; i <= (num >> 2); i++)
for (int j = l; j <= r; j++)
if (x + X[j] * i < 0 || y... | ### Prompt
In Cpp, your task is to solve the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares:
1. squares with each ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.