#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int t; cin >> t;
while (t--) {
int n, m; cin >> n >> m;
bool flip = 0;
if (n > m) {
swap(n, m);
flip = 1;
}
vector<int> cnt(m), ord(m); iota(ord.begin(), ord.end(), 0);
int cut = (n - 1) / 2, need = m / 2 + 1;
int x = m * cut / need;
cout << m + x << "\n";
vector a(n, vector<char>(m, '-'));
for (int i = 0; i < x; ++i) {
sort(ord.begin(), ord.end(), [&](int a, int b) {
return cnt[a] < cnt[b];
});
for (int j = 0; j < need; ++j) {
a[i][ord[j]] = '+';
}
}
if (flip) {
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
cout << char(a[j][i] ^ '+' ^ '-');
}
cout << "\n";
}
} else {
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
cout << a[i][j];
}
cout << "\n";
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
0 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 |
Incorrect |
1 ms |
508 KB |
in the table A+B is not equal to 41 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
1516 KB |
in the table A+B is not equal to 10 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
1368 KB |
in the table A+B is not equal to 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
Incorrect |
1 ms |
508 KB |
in the table A+B is not equal to 41 |
5 |
Halted |
0 ms |
0 KB |
- |