#include<bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
template<typename T>
using vvector = vector<vector<T>>;
void solve() {
int n,m;
cin>>n>>m;
if (min(n,m)==1) {
if (n==1) {
cout<<m<<"\n";
for (int j=1;j<=m;j++) cout<<"-";
cout<<"\n";
} else {
cout<<n<<"\n";
for (int i=1;i<=n;i++) cout<<"+\n";
}
} else if (min(n,m)==2) {
if (n==2) {
cout<<m<<"\n";
for (int i=1;i<=n;i++) {
for (int j=1;j<=m;j++) cout<<"-";
cout<<"\n";
}
} else {
cout<<n<<"\n";
for (int i=1;i<=n;i++) {
for (int j=1;j<=m;j++) cout<<"+";
cout<<"\n";
}
}
} else if (min(n,m)==3) {
if (n==3) {
cout<<m+1<<"\n";
for (int i=1;i<=n;i++) {
for (int j=1;j<=m;j++) cout<<(i==3?'+':'-');
cout<<"\n";
}
} else {
cout<<n+1<<"\n";
for (int i=1;i<=n;i++) {
for (int j=1;j<=m;j++) cout<<(j==3?'-':'+');
cout<<"\n";
}
}
} else {
cout<<(n+m-4+(n&1)+(m&1))<<"\n";
for (int i=1;i<=n;i++) {
for (int j=1;j<=m;j++) {
if (i>n-2+(n&1)) cout<<"-";
else if (j>m-2+(m&1)) cout<<"+";
else cout<<((i+j)&1?'-':'+');
}
cout<<"\n";
}
}
}
int main() {
speed;
int t;
cin>>t;
while (t--) {
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |