#include <bits/stdc++.h>
#define pb push_back
#define ALL(x) x.begin(),x.end()
using namespace std;
int n, m;
char a = '+', b = '-';
const int N = 1e3+1;
char ans[N][N];
void go() {
bool flip = 0;
cin >> n >> m;
if (n > m) {
flip = 1;
swap(n, m);
swap(a, b);
// reverse(ALL(s));
}
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) ans[i][j] = b;
int changeCnt = m * ((n-1)/2), curLine = 0, curPick = 0;
for (int i = 0; changeCnt>0; i++) {
ans[curLine][i%m] = a;
changeCnt--, curPick++;
if (curPick*2 > m) {
curLine++;
curPick = 0;
}
}
cout << m + curLine <<'\n';
if (flip) swap(n, m), swap(a, b);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) cout << (flip ? ans[j][i] : ans[i][j]);
cout << '\n';
}
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
int T; cin >> T;
while(T--) go();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
1412 KB |
Output is correct |
2 |
Correct |
23 ms |
1936 KB |
Output is correct |
3 |
Correct |
21 ms |
1908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
1328 KB |
Output is correct |
2 |
Correct |
27 ms |
1808 KB |
Output is correct |
3 |
Correct |
18 ms |
1612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
34 ms |
1412 KB |
Output is correct |
6 |
Correct |
23 ms |
1936 KB |
Output is correct |
7 |
Correct |
21 ms |
1908 KB |
Output is correct |
8 |
Correct |
36 ms |
1328 KB |
Output is correct |
9 |
Correct |
27 ms |
1808 KB |
Output is correct |
10 |
Correct |
18 ms |
1612 KB |
Output is correct |
11 |
Correct |
5 ms |
588 KB |
Output is correct |
12 |
Correct |
18 ms |
1516 KB |
Output is correct |
13 |
Correct |
21 ms |
1508 KB |
Output is correct |
14 |
Correct |
19 ms |
1312 KB |
Output is correct |
15 |
Correct |
25 ms |
2252 KB |
Output is correct |
16 |
Correct |
18 ms |
1780 KB |
Output is correct |
17 |
Correct |
8 ms |
1100 KB |
Output is correct |