# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
218328 | Lawliet | Red-blue table (IZhO19_stones) | C++17 | 58 ms | 1912 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 <bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
int n, m;
int freq[MAXN];
char ans[MAXN][MAXN];
char aux[MAXN][MAXN];
int main()
{
int t;
scanf("%d",&t);
for(int k = 0 ; k < t ; k++)
{
scanf("%d %d",&n,&m);
int qtdColumn = m;
int optQtdLine = 0;
int optQtdColumn = m;
int A = m/2 + 1 - m;
int B = (n - 1)/2;
for(int qtdLines = 0 ; qtdLines <= n ; qtdLines++)
{
while( qtdLines*( A + qtdColumn ) > qtdColumn*B )
qtdColumn--;
if( optQtdLine + optQtdColumn < qtdLines + qtdColumn )
{
optQtdLine = qtdLines;
optQtdColumn = qtdColumn;
}
}
printf("%d\n",optQtdLine + optQtdColumn);
for(int i = 1 ; i <= optQtdLine ; i++)
freq[i] = m/2 + 1;
int curCnt = 0;
int curLine = 1;
int curColumn = 1;
for(int i = 1 ; i <= n ; i++)
for(int j = 1 ; j <= m ; j++)
ans[i][j] = 'x';
while( curColumn <= optQtdColumn )
{
if( freq[curLine] == 0 ) break;
ans[curLine][curColumn] = '+';
curCnt++;
freq[ curLine++ ]--;
if( curCnt == m - m/2 - 1 )
{
curCnt = 0;
curColumn++;
}
if( curLine == optQtdLine + 1 )
curLine = 1;
}
for(int i = 1 ; i <= optQtdLine ; i++)
for(int j = optQtdColumn + 1 ; j <= m ; j++)
ans[i][j] = '+';
for(int i = 1 ; i <= n ; i++)
for(int j = 1 ; j <= m ; j++)
if( ans[i][j] == 'x' ) ans[i][j] = '-';
for(int i = 1 ; i <= n ; i++, printf("\n"))
for(int j = 1 ; j <= m ; j++)
printf("%c",ans[i][j]);
}
}
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... |