#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ull unsigned ll
#define ld long double
#define pb push_back
#define ppb pop_back
#define clr clear
#define len size()
#define beg begin()
#define end end()
#define ins insert
#define f first
#define s second
#define y1 y123456789
#define forn(i, l, r) for(int i = l; i <= r; ++i)
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;
using namespace __gnu_pbds;
typedef tree < int, null_type, greater_equal < int >,
rb_tree_tag, tree_order_statistics_node_update > ordered_set;
int t, n, m;
const int MAXN = 1020;
int cnt[MAXN];
char a[MAXN][MAXN];
int add(int y)
{
if (y == n)
return 1;
return y + 1;
}
int main()
{
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
fastio;
cin >> t;
while (t--)
{
memset(cnt, 0, sizeof(cnt));
cin >> n >> m;
bool tr = n < m;
if (tr)
swap(n, m);
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= m; ++j)
a[i][j] = '+';
int y = 1, x = 1, ans = n, c = 0;
while (true)
{
if (c == n * ((m - 1) / 2))
break;
a[y][x] = '-';
++cnt[x];
++c;
if (cnt[x] == n / 2 + 1)
++x, ++ans;
y = add(y);
}
cout << ans << '\n';
if (tr)
{
for (int i = 1; i <= m; ++i)
{
for (int j = 1; j <= n; ++j)
cout << (a[j][i] == '+' ? '-' : '+');
cout << '\n';
}
}
else
{
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
cout << a[i][j];
cout << '\n';
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
2 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
1492 KB |
Output is correct |
2 |
Correct |
22 ms |
2124 KB |
Output is correct |
3 |
Correct |
18 ms |
2012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
1476 KB |
Output is correct |
2 |
Correct |
18 ms |
1756 KB |
Output is correct |
3 |
Correct |
16 ms |
1584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
2 ms |
312 KB |
Output is correct |
5 |
Correct |
23 ms |
1492 KB |
Output is correct |
6 |
Correct |
22 ms |
2124 KB |
Output is correct |
7 |
Correct |
18 ms |
2012 KB |
Output is correct |
8 |
Correct |
21 ms |
1476 KB |
Output is correct |
9 |
Correct |
18 ms |
1756 KB |
Output is correct |
10 |
Correct |
16 ms |
1584 KB |
Output is correct |
11 |
Correct |
6 ms |
588 KB |
Output is correct |
12 |
Correct |
17 ms |
1868 KB |
Output is correct |
13 |
Correct |
20 ms |
1988 KB |
Output is correct |
14 |
Correct |
13 ms |
1612 KB |
Output is correct |
15 |
Correct |
24 ms |
2260 KB |
Output is correct |
16 |
Correct |
17 ms |
1892 KB |
Output is correct |
17 |
Correct |
7 ms |
1220 KB |
Output is correct |