#include<bits/stdc++.h>
#define loop(n) for(int i=0; i<n; i++)
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define p_b push_back
#define l_b lower_bound
#define u_b upper_bound
#define m_p make_pair
#define m_t make_tuple
#define ar array
using namespace std;
const int M=1e9, mxN=1e5;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
//cout.tie(NULL);
int T;
cin>>T;
while(T--){
int n, m, ans=0;
cin>>n>>m;
char a[n][m];
if(n<m){
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
a[i][j]='-';
}
}
int x=m/2+1, y=n/2-(n%2==0);
// cout<<x<<' '<<y<<endl;
for(int i=0; i<y; i++){
for(int j=0; j<x; j++){
a[i][j]='+';
}
}
ans=m+y;
// cout<<x<<' '<<abs(n-(y*2))<<endl;
if(y>abs(m-(x*2))){
for(int i=y; i<y+y; i++){
for(int j=x-abs(m-(x*2)); j<x-abs(m-(x*2))+x; j++){
a[i][j]='+';
}
}
ans+=m-(x*2)+y;
}
cout<<ans<<'\n';
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
cout<<a[i][j];
}
cout<<'\n';
}
}
else {
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
a[i][j]='+';
}
}
int x=m/2-(m%2==0), y=n/2+1;
// cout<<x<<' '<<y<<endl;
for(int i=0; i<y; i++){
for(int j=0; j<x; j++){
a[i][j]='-';
}
}
ans=n+x;
// cout<<x<<' '<<abs(n-(y*2))<<endl;
if(x>abs(n-(y*2))){
for(int i=y-abs(n-(y*2)); i<y-abs(n-(y*2))+y; i++){
for(int j=x; j<x+x; j++){
a[i][j]='-';
}
}
ans+=n-(y*2)+x;
}
cout<<ans<<'\n';
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
cout<<a[i][j];
}
cout<<'\n';
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Incorrect |
1 ms |
332 KB |
Wrong answer in test 38 5: 40 < 41 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1204 KB |
Output is correct |
2 |
Correct |
20 ms |
1744 KB |
Output is correct |
3 |
Correct |
18 ms |
1760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
1224 KB |
Wrong answer in test 6 6: 8 < 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Incorrect |
1 ms |
332 KB |
Wrong answer in test 38 5: 40 < 41 |