#include <bits/stdc++.h>
#define pb push_back
#define ALL(x) x.begin(),x.end()
using namespace std;
int n, m;
string s = "+-";
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);
reverse(ALL(s));
}
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) ans[i][j] = s[1];
int changeCnt = m * ((n-1)/2), curLine = 0, curPick = 0;
for (int i = 0; changeCnt>0; i++) {
ans[curLine][i%m] = s[0];
changeCnt--, curPick++;
if (curPick*2 > m) {
curLine++;
curPick = 0;
}
}
cout << m + curLine <<'\n';
if (flip) swap(n, m), reverse(ALL(s));
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 |
1 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 |
1 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 |
24 ms |
1424 KB |
Output is correct |
2 |
Correct |
29 ms |
1920 KB |
Output is correct |
3 |
Correct |
22 ms |
1860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1376 KB |
Output is correct |
2 |
Correct |
19 ms |
1848 KB |
Output is correct |
3 |
Correct |
17 ms |
1596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 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 |
24 ms |
1424 KB |
Output is correct |
6 |
Correct |
29 ms |
1920 KB |
Output is correct |
7 |
Correct |
22 ms |
1860 KB |
Output is correct |
8 |
Correct |
24 ms |
1376 KB |
Output is correct |
9 |
Correct |
19 ms |
1848 KB |
Output is correct |
10 |
Correct |
17 ms |
1596 KB |
Output is correct |
11 |
Correct |
6 ms |
588 KB |
Output is correct |
12 |
Correct |
27 ms |
1600 KB |
Output is correct |
13 |
Correct |
31 ms |
1612 KB |
Output is correct |
14 |
Correct |
19 ms |
1228 KB |
Output is correct |
15 |
Correct |
27 ms |
2292 KB |
Output is correct |
16 |
Correct |
17 ms |
1740 KB |
Output is correct |
17 |
Correct |
8 ms |
1048 KB |
Output is correct |