#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1005;
char ans[N][N];
void Solve(){
int n, m;
cin >> n >> m;
bool bad = false;
if(n > m){
swap(n, m);
bad = true;
}
int i, j;
int res;
if(n <= 2){
for(i=0;i<n;i++)
for(j=0;j<m;j++)ans[i][j] = '-';
res = m;
}else if(n <= 4){
for(i=0;i<(n+2)/2;i++)
for(j=0;j<m;j++)ans[i][j] = '+';
for(i=(n+2)/2;i<n;i++)
for(j=0;j<m;j++)ans[i][j] = '-';
res = m+((n-1)/2);
}else {
for(i=0;i<n;i++)
for(j=0;j<m;j++)ans[i][j] = '-';
int have = 0;
i=0;
j=0;
int need = (n+2)/2;
int toans = 0;
while(true){
if(have == need)i++,have=0, toans++;
if(i == n)break;
ans[i][j] = '+';
j++;
if(j == m)j=0;
have++;
}res = toans + m;
}
cout << res << '\n';
if(bad){
for(i=0;i<n;i++)
for(j=0;j<m;j++)
if(ans[i][j] == '+')ans[i][j] = '-';
else ans[i][j] = '+';
for(j=0;j<m;j++){
for(i=0;i<n;i++)
cout << ans[i][j];
cout << '\n';
}
}
else
for(i=0;i<n;i++){
for(j=0;j<m;j++)
cout << ans[i][j];
cout << '\n';
}
}
signed main(){
int t;
cin >> t;
while(t--)Solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
in the table A+B is not equal to 4 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
in the table A+B is not equal to 46 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
in the table A+B is not equal to 4 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
46 ms |
1388 KB |
in the table A+B is not equal to 118 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
46 ms |
1444 KB |
in the table A+B is not equal to 48 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
in the table A+B is not equal to 4 |
2 |
Halted |
0 ms |
0 KB |
- |