제출 #223786

#제출 시각아이디문제언어결과실행 시간메모리
223786sochoRed-blue table (IZhO19_stones)C++14
27 / 100
82 ms1400 KiB
#include "bits/stdc++.h"
using namespace std;
// #define endl '\n'
// #define double long double
// #define int long long
// int MOD = 1000 * 1000 * 1000 + 7;
// int MOD = 998244353;

void solve() {
	
	int n, m;
	cin >> n >> m;
	
	bool grid[n][m]; // 1 is +, 0 is -
	memset(grid, 1, sizeof grid);
	
	int best = n;
	int bX = n;
	int bA = m;
	
	for (int x=0; x<=n; x++) {
		int y = n - x;
		for (int a=0; a<=m; a++) {
			int b = m - a;
			
			int ans = 0;
			if (x > y) {
				ans += b;
			}
			else if (y > x) {
				ans += a;
			}
			if (a > b) {
				ans += x;
			}
			else if (b > a) {
				ans += y;
			}
			
			if (ans > best) {
				best = ans;
				bX = x;
				bA = a;
			}
			
		}
	}
	
	for (int i=0; i<bX; i++) {
		for (int j=bA; j<m; j++) {
			grid[i][j] = 0;
		}
	}
	for (int i=bX; i<n; i++) {
		for (int j=0; j<bA; j++) {
			grid[i][j] = 0;
		}
	}
	
	cout << best << endl;
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			if (grid[i][j]) cout << '+';
			else cout << '-';
		}
		cout << endl;
	}
	
}

signed main() {
	
	int t;
	cin >> t;
	while (t--) solve();
	
}
#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...