Submission #501716

# Submission time Handle Problem Language Result Execution time Memory
501716 2022-01-04T10:59:36 Z Mazaalai Red-blue table (IZhO19_stones) C++17
38 / 100
26 ms 1260 KB
#include <bits/stdc++.h>
using namespace std;
string s = "+-";
void go() {
	int n, m;
	cin >> n >> m;
	if (n == 1) {
		cout << m << '\n';
		for (int i = 0; i < m; i++) cout << s[1];
		cout << '\n';
		return;
	}
	if (m == 1) {
		cout << n << '\n';
		for (int i = 0; i < n; i++) cout << s[0] << '\n';
		return;
	}
	if (n == 2) {
		cout << m << '\n';
		for (int i = 0; i < m; i++) cout << s[1];
		cout << '\n';
		for (int i = 0; i < m; i++) cout << s[1];
		cout << '\n';
		return;	
	}
	if (m == 2) {
		cout << n << '\n';
		for (int i = 0; i < n; i++) cout << s[0] << s[0] << '\n';
		return;
	}
	if (n == 3) {
		cout << m+1 << '\n';
		for (int i = 0; i < m; i++) cout << s[1];
		cout << '\n';
		for (int i = 0; i < m; i++) cout << s[1];
		cout << '\n';
		for (int i = 0; i < m; i++) cout << s[0];
		cout << '\n';
		return;
	}
	if (m == 3) {
		cout << n+1 << '\n';
		for (int i = 0; i < n; i++) cout << s[0] << s[0] << s[1] << '\n';
		return;
	}
	if (n & 1 && m & 1) {
		cout << n+m-2 << '\n';
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (i == n) cout << s[1];
				else if (j == m) cout << s[0];
				else cout << s[(i+j)%2];
			}
			cout << '\n';
		}
		return;
	}
	if (n == 4) {
		cout << m+1 << '\n';
		for (int i = 0; i < m; i++) cout << s[1];
		cout << '\n';
		for (int i = 0; i < m; i++) cout << s[1];
		cout << '\n';
		for (int i = 0; i < m; i++) cout << s[1];
		cout << '\n';
		for (int i = 0; i < m; i++) cout << s[0];
		cout << '\n';
		return;
	}
	if (m == 4) {
		cout << n+1 << '\n';
		for (int i = 0; i < n; i++) cout << s[0] << s[0] << s[0] << s[1] << '\n';
		return;
	}
	if (n == 5) {
		cout << m+2 << '\n';
		for (int i = 0; i < m; i++) cout << s[1];
		cout << '\n';
		for (int i = 0; i < m; i++) cout << s[1];
		cout << '\n';
		for (int i = 0; i < m; i++) cout << s[1];
		cout << '\n';
		for (int i = 0; i < m; i++) cout << s[0];
		cout << '\n';
		for (int i = 0; i < m; i++) cout << s[0];
		cout << '\n';
		return;
	}
	if (m == 5) {
		cout << n+2 << '\n';
		for (int i = 0; i < n; i++) cout << s[0] << s[0] << s[0] << s[1] << s[1] << '\n';
		return;
	}
	if (n % 2 == 0 && m % 2 == 0) {
		cout << n+m-4 << '\n';
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (i == n || i == n-1) cout << s[1];
				else if (j == m || j == m-1) cout << s[0];
				else cout << s[(i+j)%2];
			}
			cout << '\n';
		}
		return;
	}

}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	int T;
	cin >> T;
	while(T--) go();

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 2 ms 356 KB Wrong answer in test 38 5: 40 < 41
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1260 KB Output is correct
2 Correct 20 ms 1100 KB Output is correct
3 Correct 20 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 1244 KB Wrong answer in test 6 6: 8 < 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 2 ms 356 KB Wrong answer in test 38 5: 40 < 41