#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
int tt;
cin >> tt;
while (tt--) {
int n, m;
cin >> n >> m;
if (n == 1) {
cout << m << '\n';
for (int i = 0; i < m; ++i) {
cout << "-";
}
cout << '\n';
continue;
}
if (m == 1) {
cout << n << '\n';
for (int i = 0; i < n; ++i) {
cout << "+\n";
}
cout << '\n';
continue;
}
cout << (n + m - 2 - (1 - n % 2) - (1 - m % 2)) << '\n';
int l;
if (m % 2 == 0) l = (m + 2) / 2;
else l = (m + 1) / 2;
int it = 0;
vector<vector<int>> ans(n, vector<int>(m));
vector<int> cnt(m);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < l; ++j) {
ans[i][it] = 1;
cnt[it]++;
it = (it + 1) % m;
}
int max1 = 0;
for (int j = 0; j < m; ++j) {
max1 = max(max1, cnt[j]);
}
if (n % 2 == 0) {
if (max1 >= (n - 1) / 2) break;
}
else if (max1 >= n / 2) break;
}
for (auto e : ans) {
for (auto u : e) {
if (u) cout << "+";
else cout << "-";
}
cout << '\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Wrong answer in test 2 4: 2 < 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
364 KB |
in the table A+B is not equal to 18 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Wrong answer in test 2 4: 2 < 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
49 ms |
1516 KB |
in the table A+B is not equal to 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
52 ms |
1388 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 |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Wrong answer in test 2 4: 2 < 4 |