Submission #203011

# Submission time Handle Problem Language Result Execution time Memory
203011 2020-02-19T02:44:58 Z luciocf Red-blue table (IZhO19_stones) C++14
15 / 100
63 ms 1912 KB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

const int maxn = 1e3+10;

pii linha[maxn];

char tab[maxn][maxn];

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

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

		int mx = n, opt = 0;

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

			if (need == 0) qtd += n;
			else
			{
				int x = (n - ((n+2)/2))*B;
				qtd += min(n, x/need);
			}

			if (qtd > mx)
				mx = qtd, opt = B;
		}

		for (int i = 1; i <= n; i++)
			linha[i] = {0, i};

		printf("%d\n", mx);

		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++)
				tab[i][j] = '-';

		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m-opt; j++)
				tab[i][j] = '+';

		for (int j = m-opt+1; j <= m; j++)
		{
			sort(linha+1, linha+n+1);

			for (int k = 1; k <= n - ((n+2)/2); k++)
			{
				tab[linha[k].second][j] = '+';
				linha[k].first++;
			}
		}

		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:16: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 376 KB Output is correct
2 Incorrect 5 ms 376 KB in the table A+B is not equal to 5
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 248 KB in the table A+B is not equal to 46
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 376 KB in the table A+B is not equal to 5
# Verdict Execution time Memory Grader output
1 Incorrect 63 ms 1528 KB in the table A+B is not equal to 78
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 63 ms 1528 KB Output is correct
2 Correct 55 ms 1912 KB Output is correct
3 Correct 49 ms 1680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 376 KB in the table A+B is not equal to 5