Submission #526595

# Submission time Handle Problem Language Result Execution time Memory
526595 2022-02-15T13:36:48 Z Zhora_004 Red-blue table (IZhO19_stones) C++17
17 / 100
27 ms 312 KB
#include <iostream>
#include <vector>

using namespace std;

bool t1(int n, int m)
{
	return max(n, m) <= 4;
}

void test_case()
{
	int n, m;
	cin >> n >> m;
	if (t1(n, m))
	{
		int mx = 0;
		vector<vector<bool>> ans;
		int k = n * m;
		for (int i = 0; i < (1 << k); i++)
		{
			vector<vector<bool>> v(n, vector<bool>(m));
			for (int j = 0; j < k; j++)
			{
				if ((i >> j) & 1)
				{
					int r = j / m, c = j % m;
					v[r][c] = 1;
				}
			}
			int A = 0, B = 0;
			for (int j = 0; j < n; j++)
			{
				int a = 0, b = 0;
				for (int k = 0; k < m; k++)
				{
					if (v[j][k]) a++;
					else b++;
				}
				if (a > b) A++;
			}
			for (int j = 0; j < m; j++)
			{
				int a = 0, b = 0;
				for (int k = 0; k < n; k++)
				{
					if (v[k][j]) a++;
					else b++;
				}
				if (b > a) B++;
			}
			if (A + B > mx) ans = v, mx = A + B;
		}
		cout << mx << "\n";
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				if (ans[i][j]) cout << '+';
				else cout << '-';
			}
			cout << "\n";
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tc;
	cin >> tc;
	while (tc--)
		test_case();

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 27 ms 288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 312 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 27 ms 288 KB Output is correct
3 Incorrect 3 ms 312 KB Wrong answer
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 204 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 27 ms 288 KB Output is correct
3 Incorrect 3 ms 312 KB Wrong answer
4 Halted 0 ms 0 KB -