#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[i][j] == '+' ? '-' : '+');
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
in the table A+B is not equal to 3 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
in the table A+B is not equal to 46 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
in the table A+B is not equal to 3 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
1384 KB |
in the table A+B is not equal to 78 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
1440 KB |
Output is correct |
2 |
Correct |
18 ms |
1852 KB |
Output is correct |
3 |
Correct |
18 ms |
1596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
in the table A+B is not equal to 3 |
2 |
Halted |
0 ms |
0 KB |
- |