답안 #218328

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
218328 2020-04-02T02:00:16 Z Lawliet Red-blue table (IZhO19_stones) C++17
15 / 100
58 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 )
		{
			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);
   ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB in the table A+B is not equal to 4
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 384 KB in the table A+B is not equal to 46
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB in the table A+B is not equal to 4
# 결과 실행 시간 메모리 Grader output
1 Incorrect 58 ms 1400 KB in the table A+B is not equal to 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 1504 KB Output is correct
2 Correct 44 ms 1912 KB Output is correct
3 Correct 40 ms 1656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB in the table A+B is not equal to 4