제출 #340789

#제출 시각아이디문제언어결과실행 시간메모리
340789NachoLibreRed-blue table (IZhO19_stones)C++14
11 / 100
33 ms1388 KiB
#include <bits/stdc++.h>
using namespace std;

int t, n, m;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> t;
	for(int ti = 1; ti <= t; ++ti) {
		cin >> n >> m;
		if(n == 1) {
			cout << m << "\n";
			for(int i = 1; i <= m; ++i) {
				cout << "-";
			}
			cout << "\n";
		} else if(m == 1) {
			cout << n << "\n";
			for(int i = 1; i <= n; ++i) {
				cout << "+";
				cout << "\n";
			}
		} else {
			int ns = (n - 1) / 2 * 2, ms = (m - 1) / 2 * 2;
			if(max(n + m / 2, m + n / 2) > ns + ms) {
				if(n > m) {
					cout << n + m / 2 << "\n";
					for(int i = 1; i <= n; ++i) {
						for(int j = 1; j <= m; ++j) {
							cout << (j <= m / 2 ? "-" : "+");
						}
						cout << "\n";
					}
				} else {
					cout << m + n / 2 << "\n";
					for(int i = 1; i <= n; ++i) {
						for(int j = 1; j <= m; ++j) {
							cout << (i > n / 2 ? "-" : "+");
						}
						cout << "\n";
					}
				}
			}
			cout << ns + ms << "\n";
			for(int i = 1; i <= n; ++i) {
				for(int j = 1; j <= m; ++j) {
					if(i > ns) {
						cout << "-";
					} else if(j > ms) {
						cout << "+";
					} else {
						cout << (((i + j) & 1) ? "-" : "+");
					}
				}
				cout << "\n";
			}
		}
		#ifdef WEEE
		cout << flush;
		#endif
	}
	cout << flush;
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...