#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const int N = 1e5 + 2;
int t, n, m;
char a[1002][1002];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t;
cin >> t;
while (t--) {
cin >> n >> m;
int ans = 0, lin = 0, col = 0;
for (int i = 0; i <= n; i++)
for (int j =0; j <= m; j++) {
if (m / 2 + 1 <= m - j || n / 2 + 1 <= n - i) {
if (ans < i + j) {
ans = i + j;
lin = i;
col = j;
}
}
else {
int l = m / 2 + 1 - (m - j);
int c = n / 2 + 1 - (n - i);
int nr = (j + l * i - 1) / l * i;
if (c <= i - nr) {
ans = i + j;
lin = i;
col = j;
}
}
}
cout << ans << "\n";
for (int i = 0; i < lin; i++)
for (int j = m - 1; j >= col; j--)
a[i][j] = '+';
for (int j = 0; j < col; j++)
for (int i = n - 1; i >= 0; i--)
a[i][j] = '-';
if (m / 2 + 1 > m - col) {
int c = m / 2 + 1 - (m - col);
int k = 0;
for (int i = 0; i < lin; i++) {
for (int j = 0; j < c; j++) {
a[i][k] = '+';
k = (k + 1) % col;
}
}
}
for (int i = lin; i < n; i++)
for (int j = col; j < m; j++)
a[i][j] = '-';
for (int i = 0; i < n; i++, cout << "\n")
for (int j = 0; j < m; j++)
cout << a[i][j];
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Incorrect |
4 ms |
316 KB |
Wrong answer in test 5 29: 31 < 32 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
32 ms |
1360 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
1328 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Incorrect |
4 ms |
316 KB |
Wrong answer in test 5 29: 31 < 32 |