#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, m;
bool g[1000][1000];
int fill(int x){
for(int i=0; i<n; ++i) fill(g[i], g[i]+m, 0);
int req = m/2, ver = n/2;
while(req <= m-req) ++req;
while(ver <= n-ver) ++ver;
req -= m-x;
for(int j=0; j<x; ++j)
for(int i=0; i<n; ++i)
g[i][j] = (j < req) ? n-i <= ver : i < ver;
int curr = x;
for(int i=0; i<n; ++i){
int s = 0;
for(int j=0; j<x; ++j) s += !g[i][j];
curr += s >= req;
}
return curr;
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
int T; cin >> T;
while(T--){
cin >> n >> m;
array<int, 2> mx = {-1, -1};
for(int x=max(0LL, m-4); x<=m; ++x){
mx = max(mx, {fill(x), x});
}
fill(mx[1]);
cout << mx[0] << '\n';
for(int i=0; i<n; ++i){
for(int j=0; j<m; ++j)
cout << (g[i][j] ? '-' : '+');
cout << '\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Incorrect |
3 ms |
332 KB |
Wrong answer in test 38 5: 40 < 41 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
1348 KB |
Output is correct |
2 |
Correct |
40 ms |
1848 KB |
Output is correct |
3 |
Correct |
38 ms |
2032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
44 ms |
1340 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 |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Incorrect |
3 ms |
332 KB |
Wrong answer in test 38 5: 40 < 41 |