#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 |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Wrong answer in test 2 1: 1 < 2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 7 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Wrong answer in test 2 1: 1 < 2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
1352 KB |
Wrong answer in test 24 24: 24 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Wrong answer in test 2 1: 1 < 2 |