#include <bits/stdc++.h>
using namespace std;
const int Nmax = 1005;
bool marked[Nmax][Nmax];
char ans[Nmax][Nmax];
int cnt[Nmax];
int my_ans;
void prec(int n, int m)
{
int i, j;
for(i=1; i<=n; ++i)
for(j=1; j<=m; ++j)
marked[i][j] = 0, cnt[j] = 0;
int nc, mc;
mc = m / 2 + 1;
nc = (n-1)/2;
int start = 1, step;
my_ans = m;
for(i=1; i<=n; ++i)
{
for(step = 1; step <= mc; ++step)
{
if(cnt[start] == nc) break;
++cnt[start];
marked[i][start] = 1;
++start;
if(start == m+1) start = 1;
}
if(step == mc + 1) ++my_ans;
}
}
void solve()
{
int n, m;
cin >> n >> m;
if(n > m) prec(m, n);
else prec(n, m);
int i, j;
if(n <= m)
{
for(i=1; i<=n; ++i)
for(j=1; j<=m; ++j)
ans[i][j] = (marked[i][j] ? '+' : '-');
}
else
{
for(i=1; i<=n; ++i)
for(j=1; j<=m; ++j)
ans[i][j] = (marked[j][i] ? '-' : '+');
}
cout << my_ans << '\n';
for(i=1; i<=n; ++i)
{
ans[i][m+1] = 0;
cout << (ans[i] + 1) << '\n';
}
}
int main()
{
// freopen("input", "r", stdin);
cin.sync_with_stdio(false); cin.tie(0);
int tests;
cin >> tests;
while(tests--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1484 KB |
Output is correct |
2 |
Correct |
4 ms |
2636 KB |
Output is correct |
3 |
Correct |
4 ms |
2764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1484 KB |
Output is correct |
2 |
Correct |
4 ms |
2508 KB |
Output is correct |
3 |
Correct |
3 ms |
2124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
6 ms |
1484 KB |
Output is correct |
6 |
Correct |
4 ms |
2636 KB |
Output is correct |
7 |
Correct |
4 ms |
2764 KB |
Output is correct |
8 |
Correct |
4 ms |
1484 KB |
Output is correct |
9 |
Correct |
4 ms |
2508 KB |
Output is correct |
10 |
Correct |
3 ms |
2124 KB |
Output is correct |
11 |
Correct |
2 ms |
588 KB |
Output is correct |
12 |
Correct |
4 ms |
2380 KB |
Output is correct |
13 |
Correct |
3 ms |
2508 KB |
Output is correct |
14 |
Correct |
4 ms |
1996 KB |
Output is correct |
15 |
Correct |
4 ms |
3276 KB |
Output is correct |
16 |
Correct |
3 ms |
2636 KB |
Output is correct |
17 |
Correct |
2 ms |
1740 KB |
Output is correct |