#include <iostream>
#include <algorithm>
#include <math.h>
//#include <vector>
//#include <stack>
//#include <queue>
//#include <map>
//#include <set>
//#include <deque>
#define ll long long
#define sz(s) (int)s.size()
#define N 200005
#define ff first
#define ss second
using namespace std;
int T, n, m;
char c[1005][1005];
int main()
{
cin >> T;
while(T--){
cin >> n >> m;
if(m % 2 == 1){
cout << n+m-2 << '\n';
for(int i = 1; i <= n; i += 2){
for(int j = 1; j <= m; j++){
if(j % 2 == 1) c[i][j] = '+';
else c[i][j] = '-';
}
}
for(int i = 2; i <= n; i += 2){
for(int j = 1; j <= m; j++){
if(j % 2 == 1) c[i][j] = '-';
else c[i][j] = '+';
}
}
for(int i = 1; i <= m; i++){
c[n][i] = '-';
}
for(int i = 1; i <= n; i++){
c[i][m] = '+';
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cout << c[i][j];
}
cout << '\n';
}
}
else {
if(n == 2){
cout << 2 << '\n';
}
else {
cout << n+m-4 << '\n';
}
for(int i = 1; i <= n; i++){
c[i][1] = '+';
c[i][2] = '+';
}
for(int i = 1; i <= m; i++){
c[n-1][i] = '-';
c[n][i] = '-';
}
for(int i = 1; i <= n-2; i++){
for(int j = 3; j <= m; j++){
if(i % 2 == 1){
if(j % 2 == 1){
c[i][j] = '-';
}
else {
c[i][j] = '+';
}
}
else {
if(j % 2 == 1){
c[i][j] = '+';
}
else {
c[i][j] = '-';
}
}
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cout << c[i][j];
}
cout << '\n';
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Wrong answer in test 1 3: 2 < 3 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
in the table A+B is not equal to 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Wrong answer in test 1 3: 2 < 3 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
1368 KB |
Wrong answer in test 1 77: 76 < 77 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
1368 KB |
in the table A+B is not equal to 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Wrong answer in test 1 3: 2 < 3 |
2 |
Halted |
0 ms |
0 KB |
- |