#include<bits/stdc++.h>
#define ll int
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,m,ind,ned1,ned2,ans,indx,indy;
char a[1005][1005];
int main(){
ios::sync_with_stdio(false);
int t;
cin >> t;
while(t--){
cin >> n >> m;
ned1 = (m + 2) / 2;
ned2 = (n + 2) / 2;
ans = 0;
for(int i=0; i<=n; i++){
int l=0,r=m,mid;
ind = 0;
while(r >= l){
mid = (l + r) / 2;
if(i * (mid - ned1 + (m - mid)) >= mid * (ned2 - (n - i))){
l = mid + 1;
ind = mid;
}
else {
r = mid - 1;
}
}
if(i + ind > ans){
ans = i + ind;
indx = i;
indy = ind;
}
}
cout << ans << endl;;
for(int i=indx+1; i<=n; i++)
for(int j=1; j<=m; j++)
a[i][j] = '-';
for(int j=indy + 1; j<=m; j++)
for(int i=1; i<=n; i++)
a[i][j] = '+';
int k = indy - ned1 + (m - indy),p;
if(k <= 0){
for(int i=1; i<=indx; i++)
for(int j=1; j<=indy; j++)
a[i][j] ='+';
}
else {
int l = 1;
for(int i=1; i<=indx; i++)
for(int j=1; j<=indy; j++)
a[i][j] = '+';
for(int i=1; i<=indx; i++){
p = k;
while(p--){
a[i][l] = '-';
l++;
if(l == indy + 1)
l = 1;
}
}
}
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++)
cout << a[i][j];
cout << endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
14 ms |
376 KB |
Output is correct |
4 |
Correct |
23 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
82 ms |
1464 KB |
Output is correct |
2 |
Correct |
36 ms |
1912 KB |
Output is correct |
3 |
Correct |
31 ms |
2080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
1528 KB |
Output is correct |
2 |
Correct |
32 ms |
1912 KB |
Output is correct |
3 |
Correct |
27 ms |
1660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
14 ms |
376 KB |
Output is correct |
4 |
Correct |
23 ms |
376 KB |
Output is correct |
5 |
Correct |
82 ms |
1464 KB |
Output is correct |
6 |
Correct |
36 ms |
1912 KB |
Output is correct |
7 |
Correct |
31 ms |
2080 KB |
Output is correct |
8 |
Correct |
62 ms |
1528 KB |
Output is correct |
9 |
Correct |
32 ms |
1912 KB |
Output is correct |
10 |
Correct |
27 ms |
1660 KB |
Output is correct |
11 |
Correct |
47 ms |
632 KB |
Output is correct |
12 |
Correct |
32 ms |
1912 KB |
Output is correct |
13 |
Correct |
33 ms |
2012 KB |
Output is correct |
14 |
Correct |
29 ms |
1656 KB |
Output is correct |
15 |
Correct |
32 ms |
2424 KB |
Output is correct |
16 |
Correct |
25 ms |
1912 KB |
Output is correct |
17 |
Correct |
13 ms |
1400 KB |
Output is correct |