#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <random>
using namespace std;
const int N = 1003, M = 103;
const int mod = 1e9 + 7;
int n, m;
int calc(int a, int b, int np)
{
return a - (np * a + b - 1) / b;
}
bool check(int a, int b)
{
if (a * b == 0)
return true;
int np = max(0, m / 2 + 1 - (m - b));
int nm = max(0, n / 2 + 1 - (n - a));
//cout << a << ' ' << b << endl << np << ' ' << nm << ' ' << calc(a, b, np) << endl;
return nm <= calc(a, b, np);
}
bool ans[N][N];
void answ(int a, int b)
{
int np = max(0, m / 2 + 1 - (m - b));
int r = 0, l = 0;
for (int i = 0; i < a * np; i++)
{
ans[r][l] = true;
l++;
l %= b;
r += i % a == 0;
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (i >= a)
cout << '-';
else if (j >= b)
cout << '+';
else
cout << (ans[i][j] ? '+' : '-');
}
cout << endl;
}
}
void solve()
{
cin >> n >> m;
int ans = 0, a = 0, b = 0;
for (int i = n; i >= 0; i--)
{
for (int j = m; j >= 0; j--)
{
if (!check(i, j))
continue;
if (i + j > ans)
{
a = i;
b = j;
ans = i + j;
}
}
}
cout << ans << endl;
answ(a, b);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout.precision(9);
cout << fixed;
int q = 1;
//cin >> q;
while (q--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
332 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
332 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
320 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
in the table A+B is not equal to 164 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
332 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |