# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
342285 | _ani | Red-blue table (IZhO19_stones) | C++17 | 47 ms | 1516 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <algorithm>
using namespace std;
char s[1002][1002];
int main()
{
int t;
cin >> t;
while (t--)
{
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
s[i][j] = '+';
int A, B, ans;
if (n > m) {
A = n; B = 0; ans = n;
}
else {
A = 0; B = m; ans = m;
}
for (int a = 1; a <= n; a++)
{
int k = (n + 1) / 2 - (n - a);
if (k == 0)
{
if (a + m > ans)
ans = a + m; A = a; B = m;
continue;
}
int b = (m / 2) * a / k;
while (k * b / a + ((k * b) % a ? 1 : 0) > m / 2)
b--;
if (a + b > ans)
ans = a + b; A = a; B = b;
}
int i = 0, j = 0;
int k = (n + 1) / 2 - (n - A);
while (i < B)
{
int cnt = 0;
while (cnt < k)
{
s[j][i] = '-';
j++;
if (j >= A)
j = 0;
cnt++;
}
i++;
}
for (int i = 0; i < B; i++)
for (int j = A; j < n; j++)
s[j][i] = '-';
cout << ans << '\n';
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
cout << s[i][j];
cout << '\n';
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |