#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = [", _print(x)
#else
#define debug(x...)
#endif
typedef pair<int, int> ii;
const int MAX = 1005;
int T, m, n;
ii C[MAX];
char a[MAX][MAX];
void solve() {
cin >> m >> n;
bool flipped = false;
if (m < n) {
flipped = true;
swap(m, n);
}
for (int i = 1; i <= m; i++) {
C[i] = {n, i};
for (int j = 1; j <= n; j++)
a[i][j] = '+';
}
int rs = m;
for (int j = 1; j <= n; j++) {
sort(C + 1, C + m + 1, greater<>());
bool valid = true;
for (int i = 1; i <= (m + 1) / 2 && valid; i++)
if (C[i].first - 1 > n / 2) {
a[C[i].second][j] = '-';
C[i].first--;
} else
valid = false;
rs += valid;
}
cout << rs << '\n';
if (flipped) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++)
cout << (a[j][i] == '+' ? '-' : '+');
cout << '\n';
}
} else {
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++)
cout << a[i][j];
cout << '\n';
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef DEBUG
freopen("../_input", "r", stdin);
#endif
cin >> T;
while (T--)
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
in the table A+B is not equal to 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
388 KB |
in the table A+B is not equal to 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
in the table A+B is not equal to 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
1444 KB |
Output is correct |
2 |
Correct |
30 ms |
2092 KB |
Output is correct |
3 |
Correct |
28 ms |
2036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
1472 KB |
in the table A+B is not equal to 46 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
in the table A+B is not equal to 6 |
3 |
Halted |
0 ms |
0 KB |
- |