output stringlengths 52 181k | instruction stringlengths 296 182k |
|---|---|
#include <bits/stdc++.h>
using namespace std;
void init() {}
void solve() {
int n, m;
scanf("%d %d\n", &n, &m);
vector<string> a(n);
for (int _n(n), i(0); i < _n; i++) getline(cin, a[i]);
int MOD = 1000003;
int res = 1;
for (int _n(n), i(0); i < _n; i++) {
int p = 0, q = 0;
for (int _n(m), j(0); j... | ### Prompt
Construct a cpp code solution to the problem outlined:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrate... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500004;
const int MOD = 1000003;
char *dd[MAXN];
int a1[MAXN], b1[MAXN];
int n, m;
void solve() {
long long ret = 1;
int cnt = 0;
for (int i = 0; i < n; i++) {
dd[i] = new char[m + 1];
scanf("%s", dd[i]);
}
memset(a1, -1, sizeof(a1));
me... | ### Prompt
Create a solution in cpp for the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated a... |
#include <bits/stdc++.h>
using namespace std;
vector<string> A;
string S;
int main() {
int M, N;
cin >> M >> N;
for (int i = 0; i < M; i++) {
cin >> S;
A.push_back(S);
}
int Ans = 1;
for (int i = 0; i < M; i++) {
bool Flag = true, T;
for (int j = 0; j < N; j++)
if (A[i][j] != '.') {
... | ### Prompt
Develop a solution in cpp to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
const int kMaxLength = 600000;
int open_le[500];
int open_up[500];
int main() {
open_up[1] = open_up[4] = 1;
open_up[2] = open_up[3] = 0;
open_le[1] = open_le[2] = 1;
open_le[3] = open_le[4] = 0;
int row, col;
cin >> row >> col;
vector<int> openleft(row, 0);
... | ### Prompt
Create a solution in CPP for the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated a... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000003;
struct A {
char a[500005];
int n, m;
char& at(const int& x, const int& y) { return a[x * m + y]; }
} ma;
int main() {
int i, j, n, m;
scanf("%d%d", &n, &m);
ma.n = n;
ma.m = m;
char str[500005];
for (i = 0; i < n; ++i) {
scanf(... | ### Prompt
Develop a solution in CPP to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
const int pi = acos(-1.);
using namespace std;
int r[500010], c[500010];
int ans = 1, n, m;
int mod = 1000003;
void calc() {
for (int i = 1; i <= n; i++) {
int cnt = 0;
if (r[i] & 1) cnt++;
if (r[i] & 2) cnt++;
r[i] = cnt;
}
for (int i = 1; i <= m; i++) {
int cnt = 0;
... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
char a[500004];
char f(int i, int j) { return a[i * m + j]; }
long long mod = 1000003;
int main() {
int i, j;
char c;
cin >> n >> m;
for ((i) = 0; (i) < (n); (i)++)
for ((j) = 0; (j) < (m); (j)++) {
cin >> a[m * i + j];
}
long long ans = 1;... | ### Prompt
Generate a Cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated as ... |
#include <bits/stdc++.h>
using namespace std;
const int BOTH = 0;
const int ODD = 1;
const int EVEN = 2;
const int IMPOSSIBLE = 3;
const int N_MAX = 500008;
const int P = 1000003;
int N, M;
int cols[N_MAX];
int rows[N_MAX];
int main() {
cin >> N >> M;
for (int i = 0; i < N_MAX; i++) cols[i] = rows[i] = BOTH;
for ... | ### Prompt
Your task is to create a cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, i... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
int f(int x, int y) { return x * m + y; }
int A(char m) {
if (m >= '3') return 1;
return -1;
}
int B(char m) {
if (m == '2' || m == '3') return 1;
return -1;
}
char s[500010];
bool a[500010], b[500010];
vector<pair<int, int> > v;
const int MOD = 1000003;
i... | ### Prompt
Generate a cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated as ... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(const T& a) {
return a > 0 ? a : -a;
}
int n;
int m;
int vx[500000], vy[500000];
char s[1000000];
int main() {
cin >> n >> m;
gets(s);
for (int i = 0; i < (n); i++) {
gets(s);
for (int j = 0; j < (m); j++)
if (s[j] != '.') {
... | ### Prompt
Generate a cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated as ... |
#include <bits/stdc++.h>
using namespace std;
const int mmod = 1000003;
char M[500001];
int row_type[500001][2] = {0};
int column_type[500001][2] = {0};
int main() {
int n, m;
scanf("%d %d", &n, &m);
for (int i = 0; i < n; i++) scanf("%s", M + i * m);
for (int i = 0; i < n; i++) row_type[i][0] = row_type[i][1] ... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, i... |
#include <bits/stdc++.h>
char state[500005];
int fix_point[500005];
int fix_cnt, cnt;
int N, M, NM;
bool func(int p, int a, int b, int f, bool is_first) {
if (state[p] & (1 << (a + (f ^ 2)))) {
printf("0\n");
return false;
} else if (state[p] & (1 << (a + f))) {
state[p] |= (1 << b);
} else {
if (... | ### Prompt
Your task is to create a CPP solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, i... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500005;
const int mod = 1000003;
int n, m;
string str[MAXN];
int lp(int k) {
bool f[2];
f[0] = f[1] = false;
for (int i = 0; i < m; i++) {
if (str[k][i] == '1' || str[k][i] == '2') f[i % 2] = true;
if (str[k][i] == '3' || str[k][i] == '4') f[1... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
#include <bits/stdc++.h>
using namespace std;
const int MAXNM = 500111;
const int QQQ = 1000003;
char S[MAXNM];
int N, M;
int GetCode(int x, int y) { return x * M + y; }
bool hprov(int x, int o) {
for (int j = 0; j < M; j++) {
char c = S[GetCode(x, j)];
if (o == 0 && (c == '3' || c == '4')) return false;
... | ### Prompt
In CPP, your task is to solve the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated ... |
#include <bits/stdc++.h>
using namespace std;
string field[500500];
bool canH[500500][2];
bool canV[500500][2];
const int MOD = 1000000 + 3;
int main() {
int n, m;
cin.sync_with_stdio(false);
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> field[i];
int ans = 1;
for (int i = 0; i < n; i++) {
for (int ... | ### Prompt
Please formulate a Cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1E6 + 3;
const int size = 5E5 + 1;
char *str[size];
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < (int)n; i++) {
str[i] = (char *)malloc(m + 1);
cin >> str[i];
}
int res = 1;
for (int i = 0; i < (int)n; i++) {
int sign = 0... | ### Prompt
Your task is to create a cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, i... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1E6 + 3;
const int size = 5E5 + 1;
char *str[size];
int main() {
int n, m;
cin >> n >> m;
for (unsigned i = 0; i < n; i++) {
str[i] = (char *)malloc(m + 1);
cin >> str[i];
}
int res = 1;
for (unsigned i = 0; i < n; i++) {
int sign = 0... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000, mod = 1000003;
string a[maxn];
void NO(void) {
cout << 0 << endl;
exit(0);
}
int main() {
int n, m;
cin >> m >> n;
for (int i = 0; i < m; i++) cin >> a[i];
vector<int> row(m, 0), col(n, 0);
for (int i = 0; i < m; i++)
for (int j =... | ### Prompt
Create a solution in CPP for the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated a... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000003;
struct A {
char a[500005];
int n, m;
char& at(const int& x, const int& y) { return a[x * m + y]; }
} ma;
int main() {
int i, j, n, m;
scanf("%d%d", &n, &m);
ma.n = n;
ma.m = m;
char str[500005];
for (i = 0; i < n; ++i) {
scanf(... | ### Prompt
Generate a Cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated as ... |
#include <bits/stdc++.h>
using namespace std;
int MOD = 1e6 + 3;
int main() {
int n, m;
scanf("%d%d", &n, &m);
char s[n][m + 1];
for (int i = (0); i < (int)(n); i++) scanf("%s", s[i]);
bool c[m][2];
bool r[n][2];
memset(c, 0, sizeof(c)), memset(r, 0, sizeof(r));
for (int i = (0); i < (int)(n); i++) {
... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10, P = 1e6 + 3;
int n, m;
string s[N];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 0; i < n; ++i) cin >> s[i];
int ans = 1;
for (int i = 0; i < n; ++i) {
int tp = -1;
for (int j = 0; j < m; ++j) {
... | ### Prompt
Generate a Cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated as ... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000003;
int Pot(int w) {
int odp = 1;
for (int i = 0; i < w; ++i) odp = (odp * 2) % MOD;
return odp;
}
int main() {
ios_base::sync_with_stdio(0);
int n, m;
cin >> n >> m;
vector<string> a(n);
for (int i = 0; i < n; ++i) cin >> a[i];
bool d... | ### Prompt
Please formulate a Cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
string s[500000];
const int mod = 1000003;
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> s[i];
int result = 1;
for (int i = 0; i < n; i++) {
bool ok1 = false, ok2 = false;
for (int j = 0; j < m; j++) {
if (j % 2 == 0 && (s[... | ### Prompt
Develop a solution in cpp to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
char BUF[500010];
int n, m;
int up[500010], down[500010], LE[500010], RI[500010];
int main() {
scanf("%d%d", &n, &m);
for (int i = 0; i < n; ++i) {
scanf("%s", &BUF);
for (int j = 0; j < m; ++j) switch (BUF[j]) {
case '1':
if (j & 1)
... | ### Prompt
Please create a solution in cpp to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
int nextInt() {
int x;
scanf("%d", &x);
return x;
}
long long nextLong() {
long long x;
scanf("%I64d", &x);
return x;
}
double nextDouble() {
double x;
scanf("%lf", &x);
return x;
}
const int BUFSIZE = 1000000;
char buf[BUFSIZE + 1];
string nextString() {
... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrate... |
#include <bits/stdc++.h>
using namespace std;
int Exit() {
cout << 0 << endl;
return 0;
}
int main() {
const long long MOD = (long long)1e6 + 3;
int n, m;
cin >> n >> m;
vector<string> b(n);
for (int _n(n), i(0); i < _n; i++) cin >> b[i];
long long ans = 1;
for (int _n(n), i(0); i < _n; i++) {
lon... | ### Prompt
Construct a cpp code solution to the problem outlined:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrate... |
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 7, M = 1e6 + 3;
string s[N];
long long solve(string ss) {
vector<bool> pos(2);
for (int i = 0; i < ss.size(); i++) {
if (ss[i] == '.') continue;
pos[(ss[i] == 'L') ^ (i % 2)] = 1;
}
if (pos[0] && pos[1]) return 0;
if (pos[0] || pos[1]) ... | ### Prompt
Construct a CPP code solution to the problem outlined:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrate... |
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long long P = 1000003LL;
int n, m;
vector<string> s;
long long solve(vector<int> a) {
int n = a.size();
vector<vector<long long> > d(n, vector<long long>(2, 0));
if (a[0] & 1) {
++d[0][0];
}
if (a[0] & 2) {
... | ### Prompt
Please formulate a CPP solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
char a[2][500010];
int vi[500010];
int mod = 1e6 + 3;
int main() {
int n, m, k, i, ans = 0, tt = 1, tmp, t, now;
bool ok = true;
scanf("%d%d", &n, &m);
for (k = 0; k < n; k++) {
tmp = 1;
scanf("%s", a[k & 1]);
for (i = 0; i < m; i++) {
if (a[k & 1][i] > '0') {
... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, sum = 0, count = 0, ans = 1;
cin >> n >> m;
char a[n + 2][m + 2];
int h[n + 2][m + 2];
int v[n + 2][m + 2];
int row[n + 2], col[m + 2];
for (int i = 0; i < n + 1; i++)
for (int j = 0; j < m + 1; j++) {
h[i][j] = -1;
v[i][... | ### Prompt
Create a solution in cpp for the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated a... |
#include <bits/stdc++.h>
using namespace std;
int solve() {
int n, m;
cin >> n >> m;
vector<int> r(n, -1);
vector<int> c(m, -1);
vector<int> v_ud = {-1, 0, 1, 1, 0};
vector<int> v_lr = {-1, 0, 0, 1, 1};
char ch;
int cnt = n + m;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
cin... | ### Prompt
Please formulate a CPP solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
const int INF = 0x3F3F3F3F;
const int MOD = 1000003;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
vector<vector<char> > mat;
int n, m;
bool isvalid(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }
int main() {
cin >> n >... | ### Prompt
Develop a solution in cpp to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
void show(T a, int n) {
for (int i = 0; i < n; ++i) cout << a[i] << ' ';
cout << endl;
}
template <class T>
void show(T a, int r, int l) {
for (int i = 0; i < r; ++i) show(a[i], l);
cout << endl;
}
const int N = 5100;
const int M = 5000;
const int... | ### Prompt
Create a solution in Cpp for the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated a... |
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int N = 1000010;
const int mod = 1000003;
int n, m;
vector<string> maze;
char buf[N];
void solve() {
maze.clear();
for (int i = 0; i < (int)(n); ++i) {
scanf("%s", buf);
maze.push_back(buf);
}
int ... | ### Prompt
In CPP, your task is to solve the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated ... |
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:65777216")
using namespace std;
const int mod = 1000003;
int row[1111111];
int col[1111111];
int main() {
int n, m;
char c;
cin >> n >> m;
for (int i(0); i < (n); i++) {
for (int j(0); j < (m); j++) {
scanf(" %c", &c);
if (c == '.') contin... | ### Prompt
Develop a solution in Cpp to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
int i, j, x, y, X, Y, n, m, r = 1, md = 1000003;
char st[500100];
vector<char> s[500100];
int le(char c) { return c == '1' || c == '2'; }
int up(char c) { return c == '1' || c == '4'; }
int main() {
scanf("%d%d", &n, &m);
for (i = 0; i < n; i++) {
scanf("%s", st);
... | ### Prompt
Please create a solution in CPP to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
char **ma;
int ty[2][4] = {{1, 1, 0, 0}, {1, 0, 0, 1}};
int pow_mod(long long a, int p, int mod) {
long long ret = 1;
while (p) {
if (p & 1) ret = ret * a % mod;
a = a * a % mod, p >>= 1;
}
return ret;
}
int main() {
int n, m, cnt;
while (scanf("%d%d", &... | ### Prompt
Your task is to create a cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, i... |
#include <bits/stdc++.h>
using namespace std;
int cmpN[500009];
int cmpM[500009];
vector<string> T;
int n, m;
bool puede(int id, bool tmp) {
for (int j = 0; j < m; j++) {
if (T[id][j] == '.') {
tmp = !tmp;
continue;
}
if (!tmp) {
if (T[id][j] == '1' || T[id][j] == '2')
;
el... | ### Prompt
In CPP, your task is to solve the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated ... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const double PI = 3.141592653589793;
const int mod = 1000003;
string mapa[500005], s;
char t[500005];
int n, m, i, j, d, res;
int main() {
scanf("%d %d", &n, &m);
for (i = 0; i < n; i++) {
scanf("%s", &t);
mapa[i] = t;
}
res = 1;
... | ### Prompt
Please formulate a cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename TT>
ostream &operator<<(ostream &s, pair<T, TT> t) {
return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream &operator<<(ostream &s, vector<T> t) {
s << "{";
for (int i = 0; i < t.size(); i++)
s << t[i] ... | ### Prompt
Please formulate a CPP solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, k, s, p;
bool f;
string A[500001];
char str[500001];
int main() {
scanf("%d%d", &n, &m);
vector<vector<int> > V(n), H(n);
for (i = 0; i < n; i++) {
V[i].resize(m);
H[i].resize(m);
scanf("%s", str);
A[i] = str;
for (j = 0; j < m; j++... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, i... |
#include <bits/stdc++.h>
using namespace std;
bool dp[2][500001][2];
char str[500001];
const int mod = 1000003;
int main() {
int n, m;
scanf("%d%d", &n, &m);
char c;
for (int i = 1; i <= n; i++) {
scanf("%s", str);
for (int j = 1; j <= m; j++)
if ((c = str[j - 1]) != '.') {
int l = 0, r = ... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
#include <bits/stdc++.h>
using namespace std;
const int maxs = 500000, key = 1000003;
char dat[maxs + 1];
int calcleft(int n, int m) {
int i, j, p;
int now, temp;
int ans = 1;
for (i = 0; i < n; i++) {
now = 2;
for (p = i * m, j = 0; j < m; j++, p++)
if (dat[p] == '1' || dat[p] == '2') {
i... | ### Prompt
Please provide a cpp coded solution to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e6 + 3;
int forb[2][500010][2];
char buf[500010];
int n, m;
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) {
scanf("%s", buf);
for (int j = 1; j <= m; j++) {
char c = buf[j - 1];
if (c == '1') {
forb[0]... | ### Prompt
Create a solution in CPP for the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated a... |
#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const double eps = 1e-9;
int M, N;
string grid[600000];
int main() {
cin >> M >> N;
for (int i = (0); i < (M); i++) cin >> grid[i];
int res = 1;
for (int i = (0); i < (M); i++) {
if (res == 0) break;
bool init = false;
bool dir... | ### Prompt
Develop a solution in CPP to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
const int N(500010), MOD(1000003);
int x[N], y[N];
char map[N];
int fail(int &a, int b) {
if (a != -1 && a != b % 2) return 1;
a = b % 2;
return 0;
}
int answer() {
int a, b, n, m, i, j;
scanf("%d%d", &n, &m);
memset(x, 255, sizeof(x));
memset(y, 255, sizeof(y));
for (i = 0; i !... | ### Prompt
Generate a Cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated as ... |
#include <bits/stdc++.h>
int r[500001], c[500001];
char x;
int n, m, i, j, sol = 1;
int main() {
scanf("%d %d\n", &n, &m);
for (i = 1; i <= n; ++i) {
for (j = 1; j <= m; ++j) {
scanf("%c", &x);
if (j & 1) {
if (x == '1' || x == '2') {
if (r[i] == 2) {
printf("0\n");
... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
#include <bits/stdc++.h>
using namespace std;
short int rows[500010], columns[500010];
string t[500010];
char s[500010];
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < (n); ++i) {
scanf("%s", s);
t[i] = s;
}
memset(rows, -1, sizeof(rows));
memset(columns, -1, sizeof(columns));
f... | ### Prompt
Create a solution in cpp for the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated a... |
#include <bits/stdc++.h>
using namespace std;
int l[(600000)], r[(600000)];
vector<int> f[(600000)];
int m, n, ans;
char buf[(600000)];
const int mod = 1000003;
int main() {
scanf("%d%d", &m, &n);
for (int i = 0; i < m; ++i) {
scanf("%s", buf);
for (int j = 0; j < n; ++j) {
char x = buf[j];
if (... | ### Prompt
Please create a solution in CPP to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
int wys, sze;
bool secik[500000];
int tab[500000];
int main() {
scanf("%d%d", &wys, &sze);
memset(secik, 0, sizeof secik);
memset(tab, -1, sizeof tab);
int res = 1;
for (int i = 0; i < wys; i++) {
string tmp;
cin >> tmp;
int ok = -1;
int ok2 = -1;
... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, i... |
#include <bits/stdc++.h>
using namespace std;
int height, width;
vector<vector<int> > field;
char line[500000 + 1];
int mult(int a, int b) { return (a * (long long)b) % 1000003; }
int codes[] = {0, 1, 3, 2};
int main() {
scanf("%d%d", &height, &width);
field.assign(height, vector<int>(width, -1));
for (int i = 0;... | ### Prompt
Construct a cpp code solution to the problem outlined:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrate... |
#include <bits/stdc++.h>
using namespace std;
struct ww {
int x, y;
};
int i, j, k, n, m, flag, s, re, num, G;
int *d[500010], dui[20], f[500010], b[500010], F[500010];
char p[500010];
vector<ww> a[500010];
inline void add(int x, int y, int z) {
a[x].push_back((ww){y, z});
a[y].push_back((ww){x, z});
if (!f[x])... | ### Prompt
Create a solution in CPP for the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated a... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 10;
const int INF = 1e9;
const int MOD = 1e6 + 3;
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
vector<int> G[MAXN];
char s[MAXN];
int n, m;
int ty[2][5] = {{0, 1, 1, 2, 2}, {0, 1, 2, 2, 1}};
long long... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrate... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000003;
const int V = 501000;
int n, m;
vector<string> str;
string tmp;
int row[V], col[V];
int main() {
scanf("%d%d", &n, &m);
str.resize(n);
for (int i = 0; i < n; i++) cin >> str[i];
memset(row, -1, sizeof(row));
memset(col, -1, sizeof(col));
... | ### Prompt
Please formulate a CPP solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500100, MOD = 1000003;
string str[MAXN];
int main() {
int R, C;
cin >> R >> C;
for (int i = 0; i < R; i++) cin >> str[i];
int ans = 1;
for (int i = 0; i < R; i++) {
bool bad[2] = {false, false};
for (int j = 0, m = 0; j < C; j++, m ^= 1) {... | ### Prompt
Please create a solution in CPP to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3fffffff;
const long long mod = 1e6 + 3;
const int maxn = 5e5 + 100;
char s[maxn];
int a[maxn];
int main() {
int n, m;
scanf("%d%d", &n, &m);
int p = 1;
for (int i = 1; i < n + 1; i++) {
scanf("%s", s + p);
p += m;
}
long long ans = 1;
... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
#include <bits/stdc++.h>
using namespace std;
char p[2000000];
long long kl[1000000], kr[1000000];
const long long MOD = 1000003ll;
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) scanf("%s", p + i * m);
long long q, R = 1;
for (int i = 0; i < n; i++) {
if (m == 1) {
if (p[... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
#include <bits/stdc++.h>
long long ans = 1;
int mod = 1000003;
int N, M;
char s[500005];
int a[500005];
bool b1 = true;
bool b3 = true;
int main() {
scanf("%d%d", &N, &M);
scanf("%s", s);
for (int i = 0; i < M; ++i) {
a[i] = 0;
}
for (int i = 0; i < M; ++i) {
if (i % 2 == 0) {
if (s[i] == '1' ||... | ### Prompt
Please create a solution in Cpp to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000003;
const int Maxd = 4;
const int dh[Maxd] = {0, 0, 1, 1};
const int dv[Maxd] = {0, 1, 1, 0};
int n, m;
vector<pair<int, int> > h, v;
int main() {
std::ios_base::sync_with_stdio(0);
cin >> n >> m;
cin.ignore();
h.resize(n);
fill(h.begin(), h.e... | ### Prompt
Develop a solution in CPP to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e6 + 3;
long long qp(long long a, long long b) {
long long ret = 1;
while (b) {
if (b & 1) (ret *= a) %= mod;
(a *= a) %= mod;
b >>= 1;
}
return ret;
}
string mp[500050];
bool cng[500050];
bool chk(int id, string s) {
int l = s.l... | ### Prompt
Create a solution in Cpp for the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated a... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000003;
char ss[555555];
string s[555555];
int main() {
int n, m, ret, flag, st, nst;
scanf("%d%d", &n, &m);
ret = 1;
for (int i = 0; i < n; i++) {
scanf("%s", ss);
s[i] = string(ss);
flag = false;
st = -1;
for (int j = 0; j < m;... | ### Prompt
Construct a cpp code solution to the problem outlined:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrate... |
#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
const long long mod = 1e6 + 3;
int dx[5] = {0, 0, 0, 1, 1};
int dy[5] = {0, 0, 1, 1, 0};
string s[N];
long long pow_q(long long a, long long b) {
long long tmp = 1;
while (b > 0) {
if (b & 1) {
tmp *= a;
tmp %= mod;
}
a *= a... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
#include <bits/stdc++.h>
char state[500005];
int fix_point[500005];
int fix_cnt;
int N, M, NM;
int main() {
int i, j, k, x, y, f, cnt = 0, m = (1e6) + 3;
char c;
scanf("%d %d", &N, &M);
getchar();
NM = N * M;
for (i = 0; i < N; i++) {
for (j = 0; j < M; j++) {
scanf("%c", &c);
if (c == '.') ... | ### Prompt
Construct a CPP code solution to the problem outlined:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrate... |
#include <bits/stdc++.h>
const int N = 500050;
const int mod = 1e6 + 3;
std::string field[N];
char buf[N];
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) {
scanf("%s", buf);
field[i] = buf;
}
int ways = 1;
for (int i = 0; i < n; i++) {
int s = 0;
for (int j = 0; j ... | ### Prompt
Develop a solution in Cpp to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000003;
bool A[2][500000][2];
int n, m, i, j, ans = 1;
int main() {
scanf("%d%d", &n, &m);
for (char c; i < n; ++i)
for (j = 0, getchar(); j < m; ++j)
if ((c = getchar()) != '.')
A[1][j][(i % 2) ^ (c == '1' || c == '4')] = true,
... | ### Prompt
Develop a solution in Cpp to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
int n, m;
scanf("%d %d", &n, &m);
string S;
set<int> H[n];
set<int> V[m];
for (int i = 0; i < (n); i++) {
cin >> S;
for (int j = 0; j < (m); j++)
if (S[j] != '.') {
int t = S[j] - '0';
... | ### Prompt
Please create a solution in Cpp to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-6;
int n, m, rows[500000], columns[500000];
int main() {
scanf("%d %d", &n, &m);
bool fixedLeak = false;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
char t;
scanf(" %c", &t);
if (t != '.') {
in... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[500005];
vector<string> g;
int hor[500005], ver[500005];
int main() {
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) {
scanf("%s", s);
string str = s;
g.push_back(str);
}
memset(hor, 0, sizeof(hor));
memset(ver, 0, sizeof(ver));
... | ### Prompt
Please formulate a Cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000003;
int main(int argc, char* argv[]) {
int n, m;
cin >> n >> m;
vector<vector<int> > a(n, vector<int>(m, 0));
for (int i = 0; i < n; i++) {
string s;
cin >> s;
for (int j = 0; j < m; j++)
if (s[j] != '.') a[i][j] = s[j] - '0';
... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(
(unsigned)chrono::system_clock::now().time_since_epoch().count());
const long long int mod = 1e6 + 3;
const long double PI = acosl(-1);
const int inf = 0x3f3f3f3f;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
;
... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
#include <bits/stdc++.h>
using namespace std;
const int max_size = 5E5;
const int mod = 1E6 + 3;
char *str[max_size + 1];
int main() {
int n, m;
cin >> n >> m;
for (unsigned i = 0; i < n; i++) {
str[i] = (char *)malloc(m + 1);
cin >> str[i];
}
int res = 1;
for (unsigned i = 0; i < n; i++) {
int ... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000;
const int MAX = 1000000;
const int inf = 999999999;
const int p1 = 104393321, p2 = 104393329;
int row[MAX][2], c[MAX][2];
int main() {
ios::sync_with_stdio(0);
int n, m;
cin >> n >> m;
for (int i = (0); i < int(n); ++i) {
for (int j = (0);... | ### Prompt
Your task is to create a CPP solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, i... |
#include <bits/stdc++.h>
using namespace std;
int testnum;
vector<vector<int> > arr;
vector<int> row;
vector<int> col;
int n, m;
void preprocess() {}
void solve() {
row.resize(n);
col.resize(m);
for (int i = 0; i < n; i++) row[i] = 0;
for (int j = 0; j < m; j++) col[j] = 0;
for (int i = 0; i < n; i++)
for... | ### Prompt
Please create a solution in CPP to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
const int NUM_MAX = 600000;
int m, n;
int marked_col[NUM_MAX];
int marked_row[NUM_MAX];
bool impossible;
void process(int i, int j, char c) {
if (c == '.') return;
int x = c - '1';
int row_val = (x < 2 ? 0 : 1);
row_val = 1 + ((row_val + j) % 2);
int col_val = (x ... | ### Prompt
Create a solution in Cpp for the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated a... |
#include <bits/stdc++.h>
using namespace std;
long n, m;
char c;
long hi[600000][3], hj[600000][3], ans;
long temp;
long l, u;
int main() {
ios_base::sync_with_stdio(0);
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) {
cin >> c;
if (c == '.') continue;
temp = c - 48... | ### Prompt
In cpp, your task is to solve the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated ... |
#include <bits/stdc++.h>
using namespace std;
int table[555555];
int tablet[555555];
int n, m;
int get_char(int i, int j) { return table[i * m + j]; }
void set_char(int i, int j, int c) { table[i * m + j] = c; }
int mod = 1000003;
bool is_consistent_row(int i, bool dir) {
for (int j = 0; j < m; j++) {
if (((j % 2... | ### Prompt
In cpp, your task is to solve the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated ... |
#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const double EPS = 1e-9;
const int MOD = 1000003;
const int INF = 1000000000;
const long long LINF = 1000000000000000000LL;
vector<string> vs;
bool row[500010], col[500010];
int main() {
int n, m, ret = 1;
cin >> n >> m;
string str;
... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000003;
char in[500010];
inline int pow(int a, int b) {
if (b == 0) return 1;
if (b == 1) return a % mod;
long long r = pow(a, b / 2);
r = (r * r) % mod;
if (b % 2) r = (r * a) % mod;
return r;
}
int n, m;
inline char f(int x, int y) { return in... | ### Prompt
Please create a solution in cpp to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
string s[500002];
int n, m;
const int mod = 1000003;
pair<bool, bool> checkRow(int r) {
bool fl = false;
bool fr = false;
for (int i = 0; i < m; ++i)
if (s[r][i] != '.')
if (s[r][i] <= '2') {
if (i % 2 == 0)
fl = true;
else
... | ### Prompt
Please create a solution in Cpp to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000003;
char s[500020];
int n, m, rez = 1, f[500020][2], g[500020][2];
int main() {
int i, j;
cin >> n >> m;
for (i = 0; i < n; ++i) {
cin >> s;
for (j = 0; j < m; ++j)
if (s[j] != '.')
f[i][j & 1 ^ (s[j] == '1' || s[j] == '2')] ... | ### Prompt
Develop a solution in cpp to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000003;
int main() {
bool row[500100][2];
bool col[500100][2];
for (int a = 0; a < 500100; a++) {
row[a][0] = false;
row[a][1] = false;
col[a][0] = false;
col[a][1] = false;
}
int n, m;
cin >> n >> m;
for (int a = 0; a < n; a++... | ### Prompt
Please create a solution in CPP to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10, B = 1e6 + 3;
int n, m, p1[N][2], p2[N][2], x, y;
long long ans = 1;
int main() {
scanf("%d%d\n", &n, &m);
char a[n + 3][m + 3];
for (int i = 0; i < n; ++i) gets(a[i]);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j)
if (a[... | ### Prompt
Create a solution in CPP for the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated a... |
#include <bits/stdc++.h>
using namespace std;
unsigned long long power_of_2(int e) {
if (e == 0) {
return 1;
}
if (e % 2 == 1) {
return (2 * power_of_2(e - 1)) % 1000003;
}
unsigned long long tmp;
tmp = power_of_2(e / 2);
return (tmp * tmp) % 1000003;
}
int main() {
int n, m;
cin >> n;
cin >... | ### Prompt
In cpp, your task is to solve the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated ... |
#include <bits/stdc++.h>
using namespace std;
const int modulo = 1000003;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int> > matr(n);
for (int i = 0; i < n; i++) matr[i].resize(m);
for (int i = 0; i < n; i++) {
string tmp;
cin >> tmp;
for (int j = 0; j < m; j++)
if (tmp[j] == '.')
... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrate... |
#include <bits/stdc++.h>
using namespace std;
const int P = 1000003;
void bad() {
puts("0");
exit(0);
}
int main() {
int n, m;
cin >> n >> m;
string s[n];
vector<vector<int> > a(n, vector<int>(m));
vector<int> A(n, 1), B(m, 1);
for (int i = 0; i < n; i++) {
cin >> s[i];
int was = -1;
for (in... | ### Prompt
Develop a solution in cpp to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
char use[500010];
long long pow(long long a, long long ti, long long p) {
if (ti == 0) return 1;
long long ret = pow(a, ti >> 1, p);
ret = (ret * ret) % p;
if (ti & 1) ret = (ret * a) % p;
return ret;
}
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0, st = 0; i < n;... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrate... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000003;
int main() {
int n, m;
vector<string> input;
cin >> n >> m;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
input.push_back(s);
}
int ans = 1;
for (int i = 0; i < n; i++) {
bool first = true;
bool dir = true;
... | ### Prompt
Generate a Cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated as ... |
#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 0, 1, 0, -1};
int dy[] = {0, 1, 0, -1, 0};
const int M = 500010;
vector<vector<int> > A, dir;
int row, col;
char str[M];
bool ok() {
int i, j, k;
for (i = 1; i <= row; i++)
for (j = 1; j <= col; j++) dir[i][j] = -1;
for (i = 1; i <= row; i++) {
... | ### Prompt
Please formulate a Cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
int g[2][500005][2];
char p[500005];
int main() {
int i, j, l, a[2], v, v1, v2, x, y;
char c;
scanf("%d%d", a, a + 1);
memset(g, 0, sizeof(g));
for (i = 0; i < a[0]; i++) {
getchar();
scanf("%s", p);
for (j = 0; j < a[1]; j++) {
c = p[j];
i... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
#include <bits/stdc++.h>
using namespace std;
bool row[500001][4];
bool col[500001][4];
int n, m;
string str[500001];
int main() {
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> str[i];
}
for (int i = 0; i < n; i++) {
for (int j = 0; j <= m; j++) {
if (str[i][j] == '.') continue;
if (st... | ### Prompt
Please formulate a cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
#include <bits/stdc++.h>
using namespace std;
const bool TH[4] = {1, 1, 0, 0};
const bool TV[4] = {0, 1, 1, 0};
const int dx[] = {1, 1, 0, 0};
const int dy[] = {1, 0, 1, 0};
int h, w;
vector<vector<int> > mat;
bool okRow(int r) {
int idx = -1;
for (int i = 0; i < w; ++i)
if (mat[r][i] != -1) {
if (idx == ... | ### Prompt
Generate a Cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustrated as ... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
int mat[1000010];
int row(int r) {
int s = r * m, e = s + m;
bool eq = false, dif = false;
for (int i = s, idx = 0; i < e; i++, idx++) {
if (mat[i] == -1) continue;
int a = mat[i] / 2;
int b = idx & 1;
if (a == b) eq = true;
if (a != b) d... | ### Prompt
Your task is to create a cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, i... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
ll powmod(ll base, ll exp, const ll MOD) {
ll ans = 1;
while (exp) {
if (exp & 1) ans = (ans * base) % MOD;
base = (base * base) % MOD;
exp >>= 1;
}
return ans;
}
ll gcd(ll a, ll b) ... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.
Each lyric consists of two ... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 3 * 1e9 + 7;
const int base = 1e9;
const int MAX = 2 * 1e6;
const double EPS = 1e-9;
const double PI = acos(-1.);
const long long O = pow(2ll, 32) - 1;
char vowels[5] = {'a', 'e', 'o', 'i', 'u'};
bool is(char x) {
for (int i ... | ### Prompt
Develop a solution in CPP to the problem described below:
You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.
Each lyric consists of two lines. Eac... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int t[500], tot;
string s[MAXN];
struct node {
int id, cnt;
char e;
} a[MAXN], b[MAXN], p;
vector<pair<int, int> > f, h;
bool cmp(node x, node y) {
return x.cnt < y.cnt || (x.cnt == y.cnt && x.e < y.e);
}
int main(void) {
t['a'] = 1;
t['... | ### Prompt
In CPP, your task is to solve the following problem:
You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.
Each lyric consists of two lines. Each lin... |
#include <bits/stdc++.h>
using namespace std;
void __print(long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void... | ### Prompt
In CPP, your task is to solve the following problem:
You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.
Each lyric consists of two lines. Each lin... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
string str[N];
string vv = "aeoiu";
vector<pair<int, int>> pos[10];
int index(char c) {
for (int i = 0; i < ((int)(vv).size()); i++)
if (vv[i] == c) return i;
return ((int)(vv).size());
}
int main() {
ios::sync_with_stdio(false);
ci... | ### Prompt
Generate a cpp solution to the following problem:
You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.
Each lyric consists of two lines. Each line c... |
#include <bits/stdc++.h>
using namespace std;
vector<string> words;
vector<int> M[1000005][5];
vector<pair<int, int> > rgt;
vector<int> lft[1000005];
int ans[100005][4];
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
string tmp;
cin >> tmp;
words.push_back(tmp);
char last = -1;... | ### Prompt
In CPP, your task is to solve the following problem:
You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.
Each lyric consists of two lines. Each lin... |
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
using namespace std;
namespace ywy {
vector<char> vec[100010];
int lsh[100010];
vector<int> chi[100010][5];
inline void print(int x) {
for (register int i = 0; i < vec[x].size(); i++) putchar(vec[x][i]);
}
char str[... | ### Prompt
Your task is to create a CPP solution to the following problem:
You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.
Each lyric consists of two line... |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, ch = getchar();
bool fg = 1;
while (ch < '0' || ch > '9') {
if (ch == '-') fg = 0;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
return fg ? x : -x;
}
map<pair<char, i... | ### Prompt
Please provide a CPP coded solution to the problem described below:
You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.
Each lyric consists of two ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.