#include <bits/stdc++.h>
using namespace std;
#define int long long
#define OYY 1000000005
#define mod 1000000007
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mid (start+end)/2
#define lim 1000005
int32_t main(){
faster
int t;cin>>t;
while(t--){
int n,m;cin>>n>>m;
if(n<m){
if(n&1){
cout<<n/2+m<<'\n';
for(int i=0;i<n;i++){
if(!(i&1)){
for(int j=0;j<m;j++)cout<<'-';
}
else {for(int j=0;j<m;j++)cout<<'+';}
cout<<'\n';
}
}
else{
int deg=n-2;
cout<<abs(deg)/2+m<<'\n';
for(int i=0;i<deg;i++){
if(!(i&1)){
for(int j=0;j<m;j++)cout<<'-';
}
else for(int j=0;j<m;j++)cout<<'+';
cout<<'\n';
}
deg=abs(deg);
if(n-deg>=2){
for(int j=0;j<m;j++)cout<<'-';
cout<<'\n';
}
deg=abs(deg-1);
if(n-deg>=1){
for(int j=0;j<m;j++)cout<<'-';
cout<<'\n';
}
}
}
else{
if(m&1){
cout<<m/2+n<<'\n';
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(!(j&1)){
cout<<'+';
}
else cout<<'-';
}
cout<<'\n';
}
}
else{
int deg=n-2;
cout<<abs(deg)/2+m<<'\n';
for(int i=0;i<deg;i++){
for(int j=0;j<m;j++){
if(!(j&1)){
cout<<'+';
}
else if(j==m-1)cout<<'+';
else cout<<'-';
}
cout<<'\n';
}
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Wrong answer |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
invalid character |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Wrong answer |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
1372 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
1372 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Wrong answer |
3 |
Halted |
0 ms |
0 KB |
- |