#include <bits/stdc++.h>
using namespace std;
int main(){
int t; cin >> t;
while(t--){
int n, m;
cin >> n >> m;
char swapped = false;
if(n < m){
m ^= n ^= m ^= n;
swapped = true;
}
char b[n][m];
for(int i = 0; i < n; i++) for(int y = 0; y < m; y++) b[i][y] = '+';
int ans = n;
int c = 0, x = 0;
for(int i = 0; i < (m - 1) / 2; i++){
for(int y = 0; y < n; y++){
b[y][x] = '-';
c++;
if(c == n / 2 + 1){
x++;
c = 0;
ans++;
}
}
}
cout << ans << '\n';
if(!swapped){
for(int y = 0; y < n; y++){
for(int x = 0; x < m; x++) cout << b[y][x];
cout << '\n';
}
}
else{
for(int y = 0; y < m; y++){
for(int x = 0; x < n; x++) cout << (b[x][y] == '+' ? '-' : '+');
cout << '\n';
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
3 ms |
800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1436 KB |
Output is correct |
2 |
Correct |
20 ms |
1880 KB |
Output is correct |
3 |
Correct |
19 ms |
1880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
1360 KB |
Output is correct |
2 |
Correct |
19 ms |
1624 KB |
Output is correct |
3 |
Correct |
17 ms |
1368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
3 ms |
800 KB |
Output is correct |
5 |
Correct |
24 ms |
1436 KB |
Output is correct |
6 |
Correct |
20 ms |
1880 KB |
Output is correct |
7 |
Correct |
19 ms |
1880 KB |
Output is correct |
8 |
Correct |
22 ms |
1360 KB |
Output is correct |
9 |
Correct |
19 ms |
1624 KB |
Output is correct |
10 |
Correct |
17 ms |
1368 KB |
Output is correct |
11 |
Correct |
7 ms |
600 KB |
Output is correct |
12 |
Correct |
24 ms |
1408 KB |
Output is correct |
13 |
Correct |
18 ms |
1548 KB |
Output is correct |
14 |
Correct |
14 ms |
1112 KB |
Output is correct |
15 |
Correct |
22 ms |
2384 KB |
Output is correct |
16 |
Correct |
17 ms |
1880 KB |
Output is correct |
17 |
Correct |
8 ms |
856 KB |
Output is correct |