# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
202111 | ZwariowanyMarcin | Red-blue table (IZhO19_stones) | C++14 | 45 ms | 4984 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
using namespace std;
const int nax = 1011;
int T, n, m;
int t[nax][nax];
int main() {
scanf ("%d", &T);
while (T--) {
scanf ("%d%d", &n, &m);
if (n == 1) {
printf ("%d\n", m);
for (int i = 1; i <= m; ++i)
printf ("-");
printf ("\n");
continue;
}
if (m == 1) {
printf ("%d\n", n);
for (int i = 1; i <= n; ++i)
printf ("+\n");
printf ("\n");
continue;
}
int ans = n + m - 2;
int N = n;
int M = m;
if (N % 2 == 0) N--, ans--;
if (M % 2 == 0) M--, ans--;
for (int row = 1; row < N; ++row)
for (int col = 1; col <= M; ++col) {
if (col == M / 2 + 1)
t[row][col] = 1;
else if (col < M / 2 + 1)
t[row][col] = (row & 1);
else
t[row][col] = !(row & 1);
}
for (int col = 1; col <= M; ++col)
t[N][col] = 0;
if (n != N) {
for (int col = 1; col <= m; ++col)
t[n][col] = 0;
}
if (m != M) {
for (int row = 1; row <= n; ++row)
t[row][m] = 1;
}
printf ("%d\n", ans);
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
printf ((t[i][j] == 1 ? "+" : "-"));
}
printf ("\n");
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |