#include<bits/stdc++.h>
using namespace std;
int n, m;
void solve(){
cin>>n>>m;
if (n==1){
cout<<m<<"\n";
for (int i=1;i<=m;i++)cout<<"-";
cout<<"\n";
return;
}
if (m==1){
cout<<n<<"\n";
for (int i=1;i<=n;i++)cout<<"+\n";
return;
}
if (n==2){
cout<<m<<"\n";
for (int i=1;i<=2;i++){
for (int j=1;j<=m;j++){
cout<<"-";
}
cout<<"\n";
}
return;
}
if (m==2){
cout<<n<<"\n";
for (int i=1;i<=n;i++){
for (int j=1;j<=2;j++){
cout<<"+";
}
cout<<"\n";
}
return;
}
if (n%2==1 && m%2==1){
cout<<n+m-2<<"\n";
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
if (i!=n && j!=m){
if ((i+j)%2==1)cout<<"-";
else cout<<"+";
continue;
}
if (i==n)cout<<"-";
else cout<<"+";
}
cout<<"\n";
}
}
}
int main(){
int t;
cin>>t;
while(t--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
1248 KB |
Output is correct |
2 |
Correct |
26 ms |
1136 KB |
Output is correct |
3 |
Correct |
26 ms |
1100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
664 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer |