#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;
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
in the table A+B is not equal to 28 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
348 KB |
in the table A+B is not equal to 28 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
21 ms |
1372 KB |
in the table A+B is not equal to 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
1368 KB |
in the table A+B is not equal to 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
348 KB |
in the table A+B is not equal to 28 |
4 |
Halted |
0 ms |
0 KB |
- |