#include <bits/stdc++.h>
#define pb push_back
#define ALL(x) x.begin(),x.end()
using namespace std;
int n, m;
const int N = 1e3+1;
bool ans[N][N];
void go() {
bool flip = 0;
cin >> n >> m;
char a = '+', b = '-';
if (n > m) {
flip = 1;
swap(n, m);
}
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) ans[i][j] = 1;
int changeCnt = m * ((n-1)/2), curLine = 0, curPick = 0;
for (int i = 0; changeCnt>0; i++) {
ans[curLine][i%m] = 0;
changeCnt--, curPick++;
if (curPick*2 > m) {
curLine++;
curPick = 0;
}
}
cout << m + curLine <<'\n';
if (flip) swap(n, m);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) cout << (flip^(flip?ans[j][i]:ans[i][j])? b:a);
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 |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1308 KB |
Output is correct |
2 |
Correct |
20 ms |
1868 KB |
Output is correct |
3 |
Correct |
19 ms |
1848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
1412 KB |
Output is correct |
2 |
Correct |
20 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 |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
24 ms |
1308 KB |
Output is correct |
6 |
Correct |
20 ms |
1868 KB |
Output is correct |
7 |
Correct |
19 ms |
1848 KB |
Output is correct |
8 |
Correct |
23 ms |
1412 KB |
Output is correct |
9 |
Correct |
20 ms |
1808 KB |
Output is correct |
10 |
Correct |
18 ms |
1612 KB |
Output is correct |
11 |
Correct |
6 ms |
460 KB |
Output is correct |
12 |
Correct |
18 ms |
1604 KB |
Output is correct |
13 |
Correct |
28 ms |
1604 KB |
Output is correct |
14 |
Correct |
14 ms |
1272 KB |
Output is correct |
15 |
Correct |
26 ms |
2264 KB |
Output is correct |
16 |
Correct |
17 ms |
1772 KB |
Output is correct |
17 |
Correct |
9 ms |
1100 KB |
Output is correct |