Submission #990465

# Submission time Handle Problem Language Result Execution time Memory
990465 2024-05-30T13:26:10 Z ToniB Red-blue table (IZhO19_stones) C++17
0 / 100
18 ms 1372 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1001;

int t, n, m;
bool ans[N][N];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);

	cin >> t;
	while (t--) {
		cin >> n >> m;
		bool swp = 0;
		if (n > m) {
			swap(n, m);
			swp = 1;
		}

		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) ans[i][j] = 0;
		}
		
		int sum = m, mx = (n - 1) / 2;
		int off = -1, pos = m / 2 + 1;

		for (int i = 1; i < m; ++i) {
			if (min(n, (pos + i - 1) / i) <= mx) {
				off = i; break;
			}
		}

		int idx = 0;
		for (int i = 0; i < min(n, m * mx / (m / 2 + 1)); ++i) {
			for (int j = idx; j < idx + m / 2 + 1; ++j) {
				ans[i][j % m] = 1;
			}
			++sum;
			idx += off;
		}
		
		cout << sum << '\n';

		if (swp) {
			for (int i = 0; i < m; ++i) {
				for (int j = 0; j < n; ++j) {
					if (ans[i][j]) cout << '-';
					else cout << '+';
				} cout << '\n';
			}
		} else {
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < m; ++j) {
					if (ans[i][j]) cout << '+';
					else cout << '-';
				} cout << '\n';
			}
		}

	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB in the table A+B is not equal to 5
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB in the table A+B is not equal to 5
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB in the table A+B is not equal to 5
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 1372 KB in the table A+B is not equal to 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 1368 KB in the table A+B is not equal to 44
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB in the table A+B is not equal to 5
3 Halted 0 ms 0 KB -