#include <bits/stdc++.h>
using namespace std;
#define debug(args...) kout("[ " + string(#args) + " ]", args)
void kout() { cerr << endl; }
template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); }
template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; }
int t, n, m;
vector<vector<char>> A, B;
vector <int> cnt;
int ansA, ansB;
void init() {
A.clear(), B.clear();
A.resize(n), B.resize(n);
for (int i = 0; i < n; i++)
A[i].resize(m), B[i].resize(m);
ansA = n, ansB = m;
}
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> t;
while (t--) {
cin >> n >> m;
init();
cnt.clear(), cnt.resize(n);
for (int i = 0; i < m; i++) {
int c = (n+2)/2;
for (int j = 0; j < n; j++) {
if (c > 0 && cnt[j] < (m-1)/2) {
A[j][i] = '-';
cnt[j]++, c--;
} else {
A[j][i] = '+';
}
}
if (!c) ansA++;
}
cnt.clear(), cnt.resize(m);
for (int i = 0; i < n; i++) {
int c = (m+2)/2;
for (int j = 0; j < m; j++) {
if (c > 0 && cnt[j] < (n-1)/2) {
B[i][j] = '+';
cnt[j]++, c--;
} else {
B[i][j] = '-';
}
}
if (!c) ansB++;
}
if (ansA > ansB) {
cout << ansA << '\n';
for (auto v : A) {
for (char c : v) {
cout << c;
}
cout << '\n';
}
} else {
cout << ansB << '\n';
for (auto v : B) {
for (char c : v) {
cout << c;
}
cout << '\n';
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Incorrect |
3 ms |
364 KB |
Wrong answer in test 5 29: 31 < 32 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
49 ms |
1644 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
47 ms |
1536 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Incorrect |
3 ms |
364 KB |
Wrong answer in test 5 29: 31 < 32 |