#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) / j;
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer in test 3 4: 4 < 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Wrong answer in test 3 45: 36 < 46 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer in test 3 4: 4 < 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
1420 KB |
Wrong answer in test 23 57: 76 < 78 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
1400 KB |
Output is correct |
2 |
Correct |
21 ms |
1732 KB |
Output is correct |
3 |
Correct |
23 ms |
1588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer in test 3 4: 4 < 5 |