#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 1e3 + 10;
int n, m;
int d[maxn];
bool check(int r, int c, int t)
{
int con = min((r - 1) / 2, c);
int nec = t * c;
return r * con >= nec;
}
char table[maxn][maxn];
void solve()
{
cin >> n >> m;
int max_res = 0, mrow = -1, mcol = -1;
for (int x = 0; x <= n; x ++)
{
int nec = n / 2 + 1 - (n - x);
nec = max(nec, 0);
int lf = 0, rf = m + 1;
while(lf + 1 < rf)
{
int mf = (lf + rf) / 2;
if (check(x, mf, nec))
lf = mf;
else
rf = mf;
}
if (x + lf > max_res)
{
max_res = x + lf;
mrow = x;
mcol = lf;
}
}
cout << max_res << endl;
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= m; j ++)
table[i][j] = '+';
for (int i = mrow + 1; i <= n; i ++)
for (int j = 1; j <= mcol; j ++)
table[i][j] = '-';
int pv = 1;
int con = min((mrow - 1) / 2, mcol);
for (int i = 1; i <= mrow; i ++)
{
for (int step = 1; step <= con; step ++)
{
if (pv > mcol)
pv = 1;
table[i][pv] = '-';
pv ++;
}
}
for (int i = 1; i <= n; i ++, cout << endl)
for (int j = 1; j <= m; j ++)
cout << table[i][j];
}
int main()
{
speed();
int t;
cin >> t;
while(t --)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
in the table A+B is not equal to 5 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
in the table A+B is not equal to 22 |
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 |
in the table A+B is not equal to 5 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
1372 KB |
in the table A+B is not equal to 118 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
1372 KB |
Output is correct |
2 |
Correct |
14 ms |
1884 KB |
Output is correct |
3 |
Correct |
13 ms |
1628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
in the table A+B is not equal to 5 |
3 |
Halted |
0 ms |
0 KB |
- |