#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve() {
int N, M;
cin >> N >> M;
bool swapped = false;
if (N > M) {
swap(N, M);
swapped = true;
}
int upHalfN = (N / 2) + 1;
int upHalfM = (M / 2) + 1;
vector<vector<char>> ans(N, vector<char>(M, '-'));
int nRow;
for (nRow = N; nRow >= 0; --nRow) {
if (nRow * upHalfM <= M * (N - upHalfN)) {
break;
}
}
vector<int> cnts(nRow, 0);
for (int i = 0; i < M; ++i) {
vector<pair<int, int>> cnds;
for (int j = 0; j < nRow; ++j) {
cnds.emplace_back(cnts[j], j);
}
sort(cnds.begin(), cnds.end());
cnds.resize(N - upHalfN);
for (auto v : cnds) {
int r = v.second;
ans[r][i] = '+';
++cnts[r];
}
}
cout << M + nRow << "\n";
if (swapped) {
for (int i = 0; i < M; ++i) {
for (int j = 0; j < N; ++j) {
cout << char(ans[j][i] ^ '+' ^ '-');
}
}
cout << "\n";
} else {
for (int i = 0; i < N; ++i) {
for (int j = 0; j < M; ++j) {
cout << ans[i][j];
}
cout << "\n";
}
}
}
int main() {
ios_base::sync_with_stdio(false);
int T;
cin >> T;
while (T--) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
66 ms |
1344 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
1380 KB |
Output is correct |
2 |
Correct |
55 ms |
1500 KB |
Output is correct |
3 |
Correct |
50 ms |
1332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Wrong answer |