#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
char jog[N][N];
int main () {
// freopen("input.txt", "r", stdin);
int t;
cin >> t;
while ( t-- ) {
int n, m, jogap = 0;
cin >> n >> m;
if (min(n, m) == 1) {
char c;
if (n == 1) c = '-';
else c = '+';
jogap = max (n, m);
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
jog[i][j] = c;
}
}
}
else if (n >= m) {
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
jog[i][j] = '1';
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m / 2 + 1; ++j) {
jog[i][j] = '+';
}
}
jogap = n + (m - (m / 2 + 1));
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
if (jog[i][j] == '1') jog[i][j] = '-';
}
}
}
else {
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
jog[i][j] = '1';
}
}
for (int i = 1; i <= m; ++i) {
for (int j = 1; j <= n / 2 + 1; ++j) {
jog[j][i] = '-';
}
}
jogap = m + (n - (n / 2 + 1));
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
if (jog[i][j] == '1') jog[i][j] = '+';
}
}
}
//
int ans = 0;
for (int i = 1; i <= n; ++i) {
int r = 0;
for (int j = 1; j <= m; ++j) {
if (jog[i][j] == '+') {
r++;
}
else r--;
}
if (r > 0) ans++;
}
for (int i = 1; i <= m; ++i) {
int b = 0;
for (int j = 1; j <= n; ++j) {
if (jog[j][i] == '-') b++;
else b--;
}
if (b > 0) ans++;
}
//
// if (jogap != ans) {
// cout << "input : " << ans << " " << n << " " << m << endl;
// }
cout << jogap << endl;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
cout << jog[i][j];
}
cout << endl;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
6 ms |
348 KB |
Output is correct |
4 |
Incorrect |
9 ms |
344 KB |
Wrong answer in test 5 29: 31 < 32 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
50 ms |
1440 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
33 ms |
1312 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
6 ms |
348 KB |
Output is correct |
4 |
Incorrect |
9 ms |
344 KB |
Wrong answer in test 5 29: 31 < 32 |
5 |
Halted |
0 ms |
0 KB |
- |