답안 #501715

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
501715 2022-01-04T10:57:59 Z Mazaalai Red-blue table (IZhO19_stones) C++17
38 / 100
25 ms 1288 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 << '\n';
		for (int i = 0; i < n; i++) cout << s[0] << s[0] << s[0] << 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();

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 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 300 KB in the table A+B is not equal to 18
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1288 KB Output is correct
2 Correct 25 ms 1132 KB Output is correct
3 Correct 17 ms 1060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 1260 KB Wrong answer in test 6 6: 8 < 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 300 KB in the table A+B is not equal to 18