#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <iomanip>
#include <stdio.h>
#include <ctime>
#include <fstream>
#include <chrono>
#define _GLIBCXX_DEBUG
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)x.size()
#define pb push_back;
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC optimize "-O3"
typedef int supertype;
using namespace std;
void solve() {
int n, m;
cin >> n >> m;
int bestI = 0, best = 0;
for (int i = 0; i <= n; i++) {
multiset <int> canAdd;
for (int i = 0; i < (m - (m / 2 + 1)); i++) {
canAdd.insert(i);
}
int now = i;
for (int j = 0; j < m; j++) {
int needAdd = max(0LL, n / 2 + 1 - (n - i));
if (needAdd > 0) {
auto t = canAdd.lower_bound(needAdd);
if (t != canAdd.end()) {
int nov = *t - needAdd;
canAdd.erase(t);
if (nov != 0)
canAdd.insert(nov);
now++;
}
}
else
now++;
}
if (now > best) {
best = now;
bestI = i;
}
}
cout << best << endl;
vector <int> plused(bestI, m / 2 + 1);
vector <vector <char>> ans(n, vector <char>(m, '-'));
for (int i = 0; i < bestI; i++) {
for (int j = 0; j < m; j++) {
ans[i][j] = '+';
}
}
for (int j = 0; j < best - bestI; j++) {
int needPlus = n / 2 + 1 - (n - bestI);
for (int i = 0; i < bestI && needPlus != 0; i++) {
if (plused[i] - 1 > m - plused[i] + 1) {
plused[i]--;
needPlus--;
}
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << ans[i][j];
}
cout << endl;
}
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
srand(time(NULL));
//freopen("sort.in", "r", stdin);
//freopen("sort.in", "r", stdin);
//int n, m, mask;
//cin >> n >> m >> mask;
//print(generate(mask, n, m));
int tests = 1;
cin >> tests;
while (tests--) {
solve();
}
return 0;
}
/*
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Wrong answer in test 4 3: 4 < 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
376 KB |
in the table A+B is not equal to 48 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Wrong answer in test 4 3: 4 < 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
143 ms |
1392 KB |
Wrong answer in test 97 21: 97 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
112 ms |
1400 KB |
in the table A+B is not equal to 37 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Wrong answer in test 4 3: 4 < 5 |