Submission #218330

# Submission time Handle Problem Language Result Execution time Memory
218330 2020-04-02T02:04:13 Z Lawliet Red-blue table (IZhO19_stones) C++17
15 / 100
70 ms 1912 KB
#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 && optQtdLine > 0 )
		{
			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

stones.cpp: In function 'int main()':
stones.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&t);
  ~~~~~^~~~~~~~~
stones.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&n,&m);
   ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB in the table A+B is not equal to 3
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 384 KB in the table A+B is not equal to 46
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB in the table A+B is not equal to 3
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 1628 KB in the table A+B is not equal to 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 51 ms 1528 KB Output is correct
2 Correct 45 ms 1912 KB Output is correct
3 Correct 40 ms 1656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB in the table A+B is not equal to 3