#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define epb emplace_back
#define pb push_back
#define inf 1e9+1
#define linf 1e18+1
using namespace std;
char ans[1001][1001];
void solve(){
int n,m;cin>>n>>m;
int mx,mxi,mxj;
int mxx;
if(m>n){
mx=m,mxi=0,mxj=m;
mxx=0;
}
else{
mx=n,mxi=n,mxj=0;
mxx=m;
}
int cx,cy;
cx=m/2+1,cy=n/2+1;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
int y=n-cy,x=max(cx-m+j,0);
if(x*i<=y*j){
if(mx<=i+j){
mx=i+j;
mxi=i;
mxj=j;
mxx=x;
}
}
}
}
cout<<mx<<"\n";
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)ans[i][j]='-';
}
int cur=0;
for(int i=1;i<=mxi;i++){
for(int j=1;j<=mxx;j++){
if(mxj==0)continue;
int p=cur%mxj;p++;
ans[i][p]='+';
cur++;
}
}
for(int i=1;i<=mxi;i++){
for(int j=mxj+1;j<=m;j++)ans[i][j]='+';
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cout<<ans[i][j];
}
cout<<"\n";
}
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);
// freopen("in.in","r",stdin);freopen("out.out","w",stdout);
int test=1;cin>>test;
while(test--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
0 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 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
1364 KB |
Output is correct |
2 |
Correct |
26 ms |
1928 KB |
Output is correct |
3 |
Correct |
24 ms |
1996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
1432 KB |
Output is correct |
2 |
Correct |
23 ms |
1732 KB |
Output is correct |
3 |
Correct |
22 ms |
1604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
Correct |
3 ms |
332 KB |
Output is correct |
5 |
Correct |
29 ms |
1364 KB |
Output is correct |
6 |
Correct |
26 ms |
1928 KB |
Output is correct |
7 |
Correct |
24 ms |
1996 KB |
Output is correct |
8 |
Correct |
28 ms |
1432 KB |
Output is correct |
9 |
Correct |
23 ms |
1732 KB |
Output is correct |
10 |
Correct |
22 ms |
1604 KB |
Output is correct |
11 |
Correct |
8 ms |
588 KB |
Output is correct |
12 |
Correct |
27 ms |
1840 KB |
Output is correct |
13 |
Correct |
27 ms |
1988 KB |
Output is correct |
14 |
Correct |
20 ms |
1612 KB |
Output is correct |
15 |
Correct |
37 ms |
2244 KB |
Output is correct |
16 |
Correct |
32 ms |
1764 KB |
Output is correct |
17 |
Correct |
9 ms |
1228 KB |
Output is correct |