#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((m - 1) / 2, c);
int nec = t * c;
///cout << r * con << " : " << nec << endl;
return r * con >= nec;
}
char table[maxn][maxn];
void solve()
{
cin >> n >> m;
//cout << check(3, 6, 1) << endl;
//exit(0);
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;
///cout << mrow << " " << mcol << 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((m - 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 |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1364 KB |
Output is correct |
2 |
Correct |
17 ms |
1880 KB |
Output is correct |
3 |
Correct |
18 ms |
2140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1368 KB |
Output is correct |
2 |
Correct |
16 ms |
1880 KB |
Output is correct |
3 |
Correct |
14 ms |
1628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
24 ms |
1364 KB |
Output is correct |
6 |
Correct |
17 ms |
1880 KB |
Output is correct |
7 |
Correct |
18 ms |
2140 KB |
Output is correct |
8 |
Correct |
24 ms |
1368 KB |
Output is correct |
9 |
Correct |
16 ms |
1880 KB |
Output is correct |
10 |
Correct |
14 ms |
1628 KB |
Output is correct |
11 |
Correct |
6 ms |
696 KB |
Output is correct |
12 |
Correct |
15 ms |
1760 KB |
Output is correct |
13 |
Correct |
16 ms |
2140 KB |
Output is correct |
14 |
Correct |
12 ms |
1720 KB |
Output is correct |
15 |
Correct |
19 ms |
2380 KB |
Output is correct |
16 |
Correct |
18 ms |
1884 KB |
Output is correct |
17 |
Correct |
7 ms |
1372 KB |
Output is correct |