Submission #202870

# Submission time Handle Problem Language Result Execution time Memory
202870 2020-02-18T12:48:09 Z luciocf Red-blue table (IZhO19_stones) C++14
27 / 100
55 ms 1484 KB
#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

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 time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 6 ms 380 KB Output is correct
4 Incorrect 7 ms 376 KB Wrong answer in test 5 29: 31 < 32
# Verdict Execution time Memory Grader output
1 Incorrect 55 ms 1400 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 1484 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 6 ms 380 KB Output is correct
4 Incorrect 7 ms 376 KB Wrong answer in test 5 29: 31 < 32