#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define pii pair<int,int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T i, U ...j) {
cout << i << ' ', abc(j...);
}
template <typename T> void printv(T l, T r) {
for (; l != r; ++l)
cout << *l << " \n"[l + 1 == r];
}
#ifdef Doludu
#define test(x...) abc("[" + string(#x) + "]", x);
#define owo freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#else
#define test(x...) void(0)
#define owo ios::sync_with_stdio(false)
#endif
const int N = 200000;
int main () {
owo;
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
assert(n & 1 && m & 1);
int num = 0, ans = -1, now = m;
vector <int> cnt(m, 0);
for (int i = 0, j = 0; i <= n; ++i) {
if (ans < now + i)
ans = now + i, num = i;
if (i == n)
break;
for (int c = 0; c < (m + 1) / 2; ++c, j = (j + 1) % m) {
now -= cnt[j] <= n / 2;
cnt[j]++;
now += cnt[j] <= n / 2;
}
}
cout << ans << endl;
for (int i = 0, j = 0; i < n; ++i) {
string now = string(m, '-');
if (i < num) {
for (int c = 0; c < (m + 1) / 2; ++c, j = (j + 1) % m) {
now[j] = '+';
}
}
cout << now << '\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
308 KB |
Output is correct |
2 |
Runtime error |
1 ms |
444 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
308 KB |
Output is correct |
2 |
Runtime error |
1 ms |
444 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
1232 KB |
Wrong answer in test 97 21: 112 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
440 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
308 KB |
Output is correct |
2 |
Runtime error |
1 ms |
444 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |