#include<bits/stdc++.h>
using namespace std;
void solve(){
int n,m;
cin >> n >> m;
bool ch=0;
if(n<m){
swap(n,m);
ch=1;
}
int a[n+1][m+1];
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
a[i][j]=1;
}
}
if(n<=2){
if(ch){
cout << m << endl;
for(int i=1;i<=m;i++){
for(int j=1;j<=n;j++){
cout << '+';
}
cout << endl;
}
}else{
cout << m << endl;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cout << '-';
}
cout << endl;
}
}
}else{
int s=n;
int q=(m+1)/2;
int z=(n/2)+1;
//cout << z << endl;
for(int i=1;i<=z;i++){
for(int j=2;j<=q;j++){
a[i][j]=0;
}
}
s+=(q-1);
int k=(m-q-1);
q++;
if(n%2==1){
if(k>1){
s--;
s+=k;
int l=n-z+1;
for(int i=l;i<=n;i++){
for(int j=q;j<m;j++){
a[i][j]=0;
}
}
}
}else{
if(k>2){
s-=2;
s+=k;
int l=n-z+1;
for(int i=l;i<=n;i++){
for(int j=q;j<m;j++){
a[i][j]=0;
}
}
}
}
if(ch){
cout << s << endl;
for(int i=1;i<=m;i++){
for(int j=1;j<=n;j++){
if(a[j][i]!=0)cout << '-';
else cout << '+';
}
cout << endl;
}
}else{
cout << s << endl;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]!=0)cout << '+';
else cout << '-';
}
cout << endl;
}
}
}
}
int main(){
int t;
cin >> t;
while(t--){
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
Wrong answer in test 2 1: 1 < 2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
376 KB |
Wrong answer in test 2 1: 1 < 2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
Wrong answer in test 2 1: 1 < 2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
96 ms |
1448 KB |
Wrong answer in test 97 21: 115 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
70 ms |
1400 KB |
Wrong answer in test 19 19: 35 < 36 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
Wrong answer in test 2 1: 1 < 2 |