Submission #202870

#TimeUsernameProblemLanguageResultExecution timeMemory
202870luciocfRed-blue table (IZhO19_stones)C++14
27 / 100
55 ms1484 KiB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e3+10;

char tab[maxn][maxn];

int main(void)
{
	int t;
	scanf("%d", &t);

	while (t--)
	{
		int n, m;
		scanf("%d %d", &n, &m);

		int mx = 0, ind = 0;
		bool flag = 0;

		for (int A = 0; A <= n; A++)
		{
			int qtd = (m+2)/2;
			int B = m-qtd;

			if (n-A >= (n+2)/2) B = m;

			if (A+B > mx)
				mx = A+B, ind = A;
		}

		for (int B = 0; B <= m; B++)
		{
			int qtd = (n+2)/2;
			int A = n-qtd;

			if (m-B >= (m+2)/2) A = n;

			if (A+B > mx)
				mx = A+B, ind = B, flag = 1;
		}

		if (flag == 0)
		{
			for (int i = 1; i <= n; i++)
			{
				for (int j = 1; j <= m; j++)
				{
					if (i <= ind && j <= (m+2)/2)
						tab[i][j] = '+';
					else
						tab[i][j] = '-';
				}
			}
		}
		else
		{
			for (int i = 1; i <= n; i++)
			{
				for (int j = 1; j <= m; j++)
				{
					if (i <= (n+2)/2 && j <= ind)
						tab[i][j] = '-';
					else
						tab[i][j] = '+';
				}
			}
		}

		printf("%d\n", mx);
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= m; j++)
				printf("%c", tab[i][j]);
			printf("\n");
		}
	}
}

Compilation message (stderr)

stones.cpp: In function 'int main()':
stones.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &t);
  ~~~~~^~~~~~~~~~
stones.cpp:17: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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...