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>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
char a[n][n];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
a[i][j] = '+';
if (n == 1) {
for (int j = 0; j < m; j++) {
a[0][j] = '-';
}
} else if (m == 1) {
for (int i = 0; i < n; i++) {
a[i][0] = '-';
}
} else if (n == 2) {
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
if (j & 1) a[i][j] = '-';
} else if (m == 2) {
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
if (i & 1) a[i][j] = '-';
} else if (m & 1) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++)
if (j & 1) a[i][j] = '-';
}
} else if (n & 1) {
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
if (i & 1) a[i][j] = '-';
}
int A = 0, B = 0;
for (int i = 0; i < n; i++) {
int cnt = 0;
for (int j = 0; j < m; j++) {
if (a[i][j] == '+') cnt++;
}
if (cnt > m / 2) A++;
}
for (int j = 0; j < m; j++) {
int cnt = 0;
for (int i = 0; i < n; i++) {
if (a[i][j] == '-') cnt++;
}
if (cnt > n / 2)B++;
}
cout << A + B << '\n';
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++)
cout << a[i][j];
cout << '\n';
}
}
return 0;
}
# | 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... |